Changeset 206295 in webkit
- Timestamp:
- Sep 23, 2016 1:20:06 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206282 r206295 1 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale 4 https://bugs.webkit.org/show_bug.cgi?id=162139 5 6 Reviewed by Michael Catanzaro. 7 8 * js/intl-invalid-locale-crash-expected.txt: Added. 9 * js/intl-invalid-locale-crash.html: Added. 10 1 11 2016-09-22 Megan Gardner <megan_gardner@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r206289 r206295 1 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale 4 https://bugs.webkit.org/show_bug.cgi?id=162139 5 6 Reviewed by Michael Catanzaro. 7 8 The crash happens in unix ports because the resolved locale is empty when system locale is "C". IntlObject 9 considers any language tag with a size < 2 to be an invalid language, so "C" is not a valid language to resolve 10 the locale. We should ensure that WTF::platformUserPreferredLanguages() never returns invalid languages, but 11 that's not enough, because languages can be overriden from the public API, so we need to handle those cases and 12 throw exceptions instead of crashing. 13 14 * runtime/IntlCollator.cpp: 15 (JSC::IntlCollator::initializeCollator): Throw a exception when we fail to resolve the locale. 16 * runtime/IntlDateTimeFormat.cpp: 17 (JSC::IntlDateTimeFormat::initializeDateTimeFormat): Ditto. 18 * runtime/IntlNumberFormat.cpp: 19 (JSC::IntlNumberFormat::initializeNumberFormat): Ditto. 20 1 21 2016-09-22 Benjamin Poulain <bpoulain@apple.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp
r205569 r206295 258 258 // 19. Set collator.[[locale]] to the value of r.[[locale]]. 259 259 m_locale = result.get(ASCIILiteral("locale")); 260 if (m_locale.isEmpty()) { 261 throwTypeError(&state, scope, ASCIILiteral("failed to initialize Collator due to invalid locale")); 262 return; 263 } 260 264 261 265 // 20. Let k be 0. -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
r205569 r206295 457 457 // 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]]. 458 458 m_locale = resolved.get(vm.propertyNames->locale.string()); 459 if (m_locale.isEmpty()) { 460 throwTypeError(&exec, scope, ASCIILiteral("failed to initialize DateTimeFormat due to invalid locale")); 461 return; 462 } 459 463 // 14. Set dateTimeFormat.[[calendar]] to the value of r.[[ca]]. 460 464 m_calendar = resolved.get(ASCIILiteral("ca")); -
trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
r205569 r206295 199 199 // 13. Set numberFormat.[[locale]] to the value of r.[[locale]]. 200 200 m_locale = result.get(ASCIILiteral("locale")); 201 if (m_locale.isEmpty()) { 202 throwTypeError(&state, scope, ASCIILiteral("failed to initialize NumberFormat due to invalid locale")); 203 return; 204 } 201 205 202 206 // 14. Set numberFormat.[[numberingSystem]] to the value of r.[[nu]]. -
trunk/Source/WTF/ChangeLog
r206274 r206295 1 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale 4 https://bugs.webkit.org/show_bug.cgi?id=162139 5 6 Reviewed by Michael Catanzaro. 7 8 Handle the case of "C" or "POSIX" locale and use "en-US" as default. That matches what ICU and other ports do, 9 as well as what layout tests expect (some tests like js/intl-collator.html pass in the bots only because we use 10 en-US as system locale in those bots). 11 12 * wtf/PlatformUserPreferredLanguagesUnix.cpp: 13 (WTF::platformLanguage): 14 1 15 2016-09-22 Filip Pizlo <fpizlo@apple.com> 2 16 -
trunk/Source/WTF/wtf/PlatformUserPreferredLanguagesUnix.cpp
r201038 r206295 36 36 { 37 37 String localeDefault(setlocale(LC_CTYPE, nullptr)); 38 if (localeDefault.isEmpty() )39 return String("c");38 if (localeDefault.isEmpty() || equalIgnoringASCIICase(localeDefault, "C") || equalIgnoringASCIICase(localeDefault, "POSIX")) 39 return ASCIILiteral("en-us"); 40 40 41 41 String normalizedDefault = localeDefault.convertToASCIILowercase(); -
trunk/Source/WebKit2/ChangeLog
r206294 r206295 1 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale 4 https://bugs.webkit.org/show_bug.cgi?id=162139 5 6 Reviewed by Michael Catanzaro. 7 8 Handle the case of "C" locale passed by the user using "en-US" as default to match what 9 WTF::platformUserPreferredLanguages() does. 10 11 * UIProcess/API/gtk/WebKitWebContext.cpp: 12 (webkit_web_context_set_preferred_languages): Remove the call to languageDidChange() because 13 overrideUserPreferredLanguages() already calls it, so we were actually notifying the observers twice. 14 1 15 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 16 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r201267 r206295 973 973 974 974 Vector<String> languages; 975 for (size_t i = 0; languageList[i]; ++i) 976 languages.append(String::fromUTF8(languageList[i]).convertToASCIILowercase().replace("_", "-")); 977 975 for (size_t i = 0; languageList[i]; ++i) { 976 // Do not propagate the C locale to WebCore. 977 if (!g_ascii_strcasecmp(languageList[i], "C") || !g_ascii_strcasecmp(languageList[i], "POSIX")) 978 languages.append(ASCIILiteral("en-us")); 979 else 980 languages.append(String::fromUTF8(languageList[i]).convertToASCIILowercase().replace("_", "-")); 981 } 978 982 WebCore::overrideUserPreferredLanguages(languages); 979 WebCore::languageDidChange();980 983 } 981 984 -
trunk/Tools/ChangeLog
r206290 r206295 1 2016-09-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 REGRESSION(r194387): Crash on github.com in IntlDateTimeFormat::resolvedOptions in C locale 4 https://bugs.webkit.org/show_bug.cgi?id=162139 5 6 Reviewed by Michael Catanzaro. 7 8 Add test cases to check the behavior when using the C locale and an invalid locale. 9 10 * TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp: 11 (testWebContextLanguages): 12 1 13 2016-09-22 Hunseop Jeong <hs85.jeong@samsung.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebContext.cpp
r197563 r206295 466 466 static void testWebContextLanguages(WebViewTest* test, gconstpointer) 467 467 { 468 static const char* expectedDefaultLanguage = "en ";468 static const char* expectedDefaultLanguage = "en-us"; 469 469 test->loadURI(kServer->getURIForPath("/").data()); 470 470 test->waitUntilLoadFinished(); … … 488 488 g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedLanguages)); 489 489 g_assert(!strncmp(mainResourceData, expectedLanguages, mainResourceDataSize)); 490 491 // When using the C locale, en-US should be used as default. 492 const char* cLanguage[] = { "C", nullptr }; 493 webkit_web_context_set_preferred_languages(test->m_webContext.get(), cLanguage); 494 GUniqueOutPtr<GError> error; 495 WebKitJavascriptResult* javascriptResult = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr()); 496 g_assert(javascriptResult); 497 g_assert(!error); 498 GUniquePtr<char> locale(WebViewTest::javascriptResultToCString(javascriptResult)); 499 g_assert_cmpstr(locale.get(), ==, "en-US"); 500 501 // When using the POSIX locale, en-US should be used as default. 502 const char* posixLanguage[] = { "POSIX", nullptr }; 503 webkit_web_context_set_preferred_languages(test->m_webContext.get(), posixLanguage); 504 javascriptResult = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr()); 505 g_assert(javascriptResult); 506 g_assert(!error); 507 locale.reset(WebViewTest::javascriptResultToCString(javascriptResult)); 508 g_assert_cmpstr(locale.get(), ==, "en-US"); 509 510 // An invalid locale should throw an exception. 511 const char* invalidLanguage[] = { "A", nullptr }; 512 webkit_web_context_set_preferred_languages(test->m_webContext.get(), invalidLanguage); 513 javascriptResult = test->runJavaScriptAndWaitUntilFinished("Intl.DateTimeFormat().resolvedOptions().locale", &error.outPtr()); 514 g_assert(!javascriptResult); 515 g_assert_error(error.get(), WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED); 490 516 } 491 517
Note: See TracChangeset
for help on using the changeset viewer.