Changeset 161861 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Jan 12, 2014, 10:26:50 PM (11 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r161840.
http://trac.webkit.org/changeset/161840
https://bugs.webkit.org/show_bug.cgi?id=126870

Caused jsscore and layout test failures (Requested by smfr on
#webkit).

Source/JavaScriptCore:

  • API/JSValueRef.cpp:

(JSValueMakeFromJSONString):

  • bindings/ScriptValue.cpp:

(Deprecated::jsToInspectorValue):

  • inspector/InspectorValues.cpp:
  • runtime/DatePrototype.cpp:

(JSC::formatLocaleDate):

  • runtime/Identifier.h:

(JSC::Identifier::characters):

  • runtime/JSStringBuilder.h:

(JSC::JSStringBuilder::append):

Source/WebCore:

  • bindings/objc/WebScriptObject.mm:

(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):

  • editing/CompositeEditCommand.cpp:

(WebCore::containsOnlyWhitespace):

  • editing/TypingCommand.cpp:

(WebCore::TypingCommand::insertText):

  • editing/VisibleUnits.cpp:

(WebCore::startOfParagraph):
(WebCore::endOfParagraph):

  • html/parser/HTMLParserIdioms.cpp:

(WebCore::stripLeadingAndTrailingHTMLSpaces):
(WebCore::parseHTMLNonNegativeInteger):

  • inspector/ContentSearchUtils.cpp:

(WebCore::ContentSearchUtils::createSearchRegexSource):

  • inspector/InspectorStyleSheet.cpp:

(WebCore::InspectorStyle::newLineAndWhitespaceDelimiters):

  • inspector/InspectorStyleTextEditor.cpp:

(WebCore::InspectorStyleTextEditor::insertProperty):
(WebCore::InspectorStyleTextEditor::internalReplaceProperty):

  • platform/Length.cpp:

(WebCore::newCoordsArray):

  • platform/LinkHash.cpp:

(WebCore::visitedLinkHash):

  • platform/graphics/Color.cpp:

(WebCore::Color::parseHexColor):
(WebCore::Color::Color):

  • platform/graphics/TextRun.h:

(WebCore::TextRun::TextRun):

  • platform/text/TextEncodingRegistry.cpp:

(WebCore::atomicCanonicalTextEncodingName):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::constructTextRun):

  • rendering/RenderCombineText.cpp:

(WebCore::RenderCombineText::width):

  • svg/SVGFontElement.cpp:

(WebCore::SVGFontElement::registerLigaturesInGlyphCache):

  • xml/XPathFunctions.cpp:

(WebCore::XPath::FunId::evaluate):

  • xml/XPathNodeSet.h:

Source/WTF:

  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::replace):

  • wtf/text/WTFString.h:

(WTF::String::isAllSpecialCharacters):

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSValueRef.cpp

    r161840 r161861  
    324324    String str = string->string();
    325325    unsigned length = str.length();
    326     if (str.is8Bit()) {
     326    if (length && str.is8Bit()) {
    327327        LiteralParser<LChar> parser(exec, str.characters8(), length, StrictJSON);
    328328        return toRef(exec, parser.tryLiteralParse());
    329329    }
    330     LiteralParser<UChar> parser(exec, str.characters16(), length, StrictJSON);
     330    LiteralParser<UChar> parser(exec, str.characters(), length, StrictJSON);
    331331    return toRef(exec, parser.tryLiteralParse());
    332332}
  • trunk/Source/JavaScriptCore/ChangeLog

    r161851 r161861  
     12014-01-12  Commit Queue  <[email protected]>
     2
     3        Unreviewed, rolling out r161840.
     4        http://trac.webkit.org/changeset/161840
     5        https://bugs.webkit.org/show_bug.cgi?id=126870
     6
     7        Caused jsscore and layout test failures (Requested by smfr on
     8        #webkit).
     9
     10        * API/JSValueRef.cpp:
     11        (JSValueMakeFromJSONString):
     12        * bindings/ScriptValue.cpp:
     13        (Deprecated::jsToInspectorValue):
     14        * inspector/InspectorValues.cpp:
     15        * runtime/DatePrototype.cpp:
     16        (JSC::formatLocaleDate):
     17        * runtime/Identifier.h:
     18        (JSC::Identifier::characters):
     19        * runtime/JSStringBuilder.h:
     20        (JSC::JSStringBuilder::append):
     21
    1222014-01-12  Darin Adler  <[email protected]>
    223
  • trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp

    r161840 r161861  
    116116    if (value.isNumber())
    117117        return InspectorBasicValue::create(value.asNumber());
    118     if (value.isString())
    119         return InspectorString::create(value.getString(scriptState));
     118    if (value.isString()) {
     119        String s = value.getString(scriptState);
     120        return InspectorString::create(String(s.characters(), s.length()));
     121    }
    120122
    121123    if (value.isObject()) {
     
    137139        PropertyNameArray propertyNames(scriptState);
    138140        object->methodTable()->getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties);
    139         for (auto& name : propertyNames) {
    140             RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, object->get(scriptState, name), maxDepth);
     141        for (size_t i = 0; i < propertyNames.size(); i++) {
     142            const Identifier& name =  propertyNames[i];
     143            JSValue propertyValue = object->get(scriptState, name);
     144            RefPtr<InspectorValue> inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth);
    141145            if (!inspectorValue)
    142146                return nullptr;
    143             inspectorObject->setValue(name.string(), inspectorValue);
     147            inspectorObject->setValue(String(name.characters(), name.length()), inspectorValue);
    144148        }
    145149        return inspectorObject;
  • trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp

    r161851 r161861  
    447447inline bool escapeChar(UChar c, StringBuilder* dst)
    448448{
    449     // Must escape < and > to prevent script execution.
    450449    switch (c) {
    451     case '\b': dst->appendLiteral("\\b"); break;
    452     case '\f': dst->appendLiteral("\\f"); break;
    453     case '\n': dst->appendLiteral("\\n"); break;
    454     case '\r': dst->appendLiteral("\\r"); break;
    455     case '\t': dst->appendLiteral("\\t"); break;
    456     case '\\': dst->appendLiteral("\\\\"); break;
    457     case '"': dst->appendLiteral("\\\""); break;
    458     case '<': dst->appendLiteral("\\u003C"); break;
    459     case '>': dst->appendLiteral("\\u003E"); break;
     450    case '\b': dst->append("\\b", 2); break;
     451    case '\f': dst->append("\\f", 2); break;
     452    case '\n': dst->append("\\n", 2); break;
     453    case '\r': dst->append("\\r", 2); break;
     454    case '\t': dst->append("\\t", 2); break;
     455    case '\\': dst->append("\\\\", 2); break;
     456    case '"': dst->append("\\\"", 2); break;
    460457    default:
    461458        return false;
     
    470467        UChar c = str[i];
    471468        if (!escapeChar(c, dst)) {
    472             // We could format c > 126 as UTF-8 instead of escaping them.
    473             if (c >= 32 || c <= 126)
     469            if (c < 32 || c > 126 || c == '<' || c == '>') {
     470                // 1. Escaping <, > to prevent script execution.
     471                // 2. Technically, we could also pass through c > 126 as UTF8, but this
     472                //    is also optional.  It would also be a pain to implement here.
     473                unsigned int symbol = static_cast<unsigned int>(c);
     474                String symbolCode = String::format("\\u%04X", symbol);
     475                dst->append(symbolCode.characters(), symbolCode.length());
     476            } else
    474477                dst->append(c);
    475             else {
    476                 // FIXME: Way too slow to do this by creating and destroying a string each time.
    477                 dst->append(String::format("\\u%04X", static_cast<unsigned>(c)));
    478             }
    479478        }
    480479    }
  • trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp

    r161840 r161861  
    163163        timeStyle = styleFromArgString(arg0String, timeStyle);
    164164
    165     RetainPtr<CFDateFormatterRef> formatter = adoptCF(CFDateFormatterCreate(kCFAllocatorDefault, adoptCF(CFLocaleCopyCurrent()).get(), dateStyle, timeStyle));
    166 
    167     if (useCustomFormat)
    168         CFDateFormatterSetFormat(formatter.get(), customFormatString.createCFString().get());
    169 
    170     RetainPtr<CFStringRef> string = adoptCF(CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, formatter.get(), floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970));
    171 
    172     return jsNontrivialString(exec, string.get());
     165    CFLocaleRef locale = CFLocaleCopyCurrent();
     166    CFDateFormatterRef formatter = CFDateFormatterCreate(0, locale, dateStyle, timeStyle);
     167    CFRelease(locale);
     168
     169    if (useCustomFormat) {
     170        CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.characters(), customFormatString.length());
     171        CFDateFormatterSetFormat(formatter, customFormatCFString);
     172        CFRelease(customFormatCFString);
     173    }
     174
     175    CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970);
     176
     177    CFRelease(formatter);
     178
     179    // We truncate the string returned from CFDateFormatter if it's absurdly long (> 200 characters).
     180    // That's not great error handling, but it just won't happen so it doesn't matter.
     181    UChar buffer[200];
     182    const size_t bufferLength = WTF_ARRAY_LENGTH(buffer);
     183    size_t length = CFStringGetLength(string);
     184    ASSERT(length <= bufferLength);
     185    if (length > bufferLength)
     186        length = bufferLength;
     187    CFStringGetCharacters(string, CFRangeMake(0, length), buffer);
     188
     189    CFRelease(string);
     190
     191    return jsNontrivialString(exec, String(buffer, length));
    173192}
    174193
  • trunk/Source/JavaScriptCore/runtime/Identifier.h

    r161840 r161861  
    5656        StringImpl* impl() const { return m_string.impl(); }
    5757       
     58        const UChar* characters() const { return m_string.characters(); }
    5859        int length() const { return m_string.length(); }
    5960       
  • trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h

    r161840 r161861  
    106106            upConvert();
    107107        }
    108         m_okay &= buffer16.tryAppend(str.characters16(), length);
     108        m_okay &= buffer16.tryAppend(str.characters(), length);
    109109    }
    110110
Note: See TracChangeset for help on using the changeset viewer.