Changeset 161861 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Jan 12, 2014, 10:26:50 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r161840 r161861 324 324 String str = string->string(); 325 325 unsigned length = str.length(); 326 if ( str.is8Bit()) {326 if (length && str.is8Bit()) { 327 327 LiteralParser<LChar> parser(exec, str.characters8(), length, StrictJSON); 328 328 return toRef(exec, parser.tryLiteralParse()); 329 329 } 330 LiteralParser<UChar> parser(exec, str.characters 16(), length, StrictJSON);330 LiteralParser<UChar> parser(exec, str.characters(), length, StrictJSON); 331 331 return toRef(exec, parser.tryLiteralParse()); 332 332 } -
trunk/Source/JavaScriptCore/ChangeLog
r161851 r161861 1 2014-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 1 22 2014-01-12 Darin Adler <[email protected]> 2 23 -
trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp
r161840 r161861 116 116 if (value.isNumber()) 117 117 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 } 120 122 121 123 if (value.isObject()) { … … 137 139 PropertyNameArray propertyNames(scriptState); 138 140 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); 141 145 if (!inspectorValue) 142 146 return nullptr; 143 inspectorObject->setValue( name.string(), inspectorValue);147 inspectorObject->setValue(String(name.characters(), name.length()), inspectorValue); 144 148 } 145 149 return inspectorObject; -
trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp
r161851 r161861 447 447 inline bool escapeChar(UChar c, StringBuilder* dst) 448 448 { 449 // Must escape < and > to prevent script execution.450 449 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; 460 457 default: 461 458 return false; … … 470 467 UChar c = str[i]; 471 468 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 474 477 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 }479 478 } 480 479 } -
trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp
r161840 r161861 163 163 timeStyle = styleFromArgString(arg0String, timeStyle); 164 164 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)); 173 192 } 174 193 -
trunk/Source/JavaScriptCore/runtime/Identifier.h
r161840 r161861 56 56 StringImpl* impl() const { return m_string.impl(); } 57 57 58 const UChar* characters() const { return m_string.characters(); } 58 59 int length() const { return m_string.length(); } 59 60 -
trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h
r161840 r161861 106 106 upConvert(); 107 107 } 108 m_okay &= buffer16.tryAppend(str.characters 16(), length);108 m_okay &= buffer16.tryAppend(str.characters(), length); 109 109 } 110 110
Note:
See TracChangeset
for help on using the changeset viewer.