Changeset 229994 in webkit


Ignore:
Timestamp:
Mar 27, 2018 3:10:41 AM (6 years ago)
Author:
Fujii Hironori
Message:

[GTK] Layout test editing/deleting/delete-surrogatepair.html crashing with CRITICAL : enchant_dict_check: assertion 'g_utf8_validate(word, len, NULL)' failed
https://bugs.webkit.org/show_bug.cgi?id=176799

Reviewed by Carlos Garcia Campos.

Source/WebCore:

The length of a surrogate-pair UTF-16 character is 2 even though
the number of characters is 1. An incorrect string length was
passed to enchant_dict_check if the string contains a
surrogate-pair character because the length was calculated by
applying UTF-16 character position to UTF-8 string.

No new tests (Covered by existing tests).

  • platform/text/enchant/TextCheckerEnchant.cpp:

(WebCore::TextCheckerEnchant::checkSpellingOfWord): Changed the
type of an argument word from CString to String. Convert a
substring of the argument into UTF-8.
(WebCore::TextCheckerEnchant::checkSpellingOfString): Pass the
original UTF-16 string to checkSpellingOfWord instead of a
converted UTF-8 string.

  • platform/text/enchant/TextCheckerEnchant.h: Changed the type of

an argument word from CString to String.

LayoutTests:

  • platform/gtk/TestExpectations: Unmarked editing/deleting/delete-surrogatepair.html.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r229983 r229994  
     12018-03-27  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [GTK] Layout test editing/deleting/delete-surrogatepair.html crashing with CRITICAL **: enchant_dict_check: assertion 'g_utf8_validate(word, len, NULL)' failed
     4        https://bugs.webkit.org/show_bug.cgi?id=176799
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * platform/gtk/TestExpectations: Unmarked editing/deleting/delete-surrogatepair.html.
     9
    1102018-03-23  Antoine Quint  <graouts@apple.com>
    211
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r229887 r229994  
    12581258webkit.org/b/175575 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay-with-slow-text-tracks.html [ Crash Pass ]
    12591259
    1260 webkit.org/b/176799 editing/deleting/delete-surrogatepair.html [ Crash ]
    1261 
    12621260webkit.org/b/176801 fast/mediastream/apply-constraints-audio.html [ Crash ]
    12631261webkit.org/b/176801 fast/mediastream/argument-types.html [ Crash Pass ]
  • trunk/Source/WebCore/ChangeLog

    r229992 r229994  
     12018-03-27  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        [GTK] Layout test editing/deleting/delete-surrogatepair.html crashing with CRITICAL **: enchant_dict_check: assertion 'g_utf8_validate(word, len, NULL)' failed
     4        https://bugs.webkit.org/show_bug.cgi?id=176799
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        The length of a surrogate-pair UTF-16 character is 2 even though
     9        the number of characters is 1. An incorrect string length was
     10        passed to enchant_dict_check if the string contains a
     11        surrogate-pair character because the length was calculated by
     12        applying UTF-16 character position to UTF-8 string.
     13
     14        No new tests (Covered by existing tests).
     15
     16        * platform/text/enchant/TextCheckerEnchant.cpp:
     17        (WebCore::TextCheckerEnchant::checkSpellingOfWord): Changed the
     18        type of an argument `word` from CString to String. Convert a
     19        substring of the argument into UTF-8.
     20        (WebCore::TextCheckerEnchant::checkSpellingOfString): Pass the
     21        original UTF-16 string to checkSpellingOfWord instead of a
     22        converted UTF-8 string.
     23        * platform/text/enchant/TextCheckerEnchant.h: Changed the type of
     24        an argument `word` from CString to String.
     25
    1262018-03-26  Ms2ger  <Ms2ger@igalia.com>
    227
  • trunk/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp

    r222130 r229994  
    6565}
    6666
    67 void TextCheckerEnchant::checkSpellingOfWord(const CString& word, int start, int end, int& misspellingLocation, int& misspellingLength)
    68 {
    69     const char* string = word.data();
    70     char* startPtr = g_utf8_offset_to_pointer(string, start);
    71     int numberOfBytes = static_cast<int>(g_utf8_offset_to_pointer(string, end) - startPtr);
     67void TextCheckerEnchant::checkSpellingOfWord(const String& word, int start, int end, int& misspellingLocation, int& misspellingLength)
     68{
     69    CString string = word.substring(start, end - start).utf8();
    7270
    7371    for (auto& dictionary : m_enchantDictionaries) {
    74         if (!enchant_dict_check(dictionary, startPtr, numberOfBytes)) {
     72        if (!enchant_dict_check(dictionary, string.data(), string.length())) {
    7573            // Stop checking, this word is ok in at least one dict.
    7674            misspellingLocation = -1;
     
    9795        return;
    9896
    99     CString utf8String = string.utf8();
    10097    int start = ubrk_first(iter);
    10198    for (int end = ubrk_next(iter); end != UBRK_DONE; end = ubrk_next(iter)) {
    10299        if (isWordTextBreak(iter)) {
    103             checkSpellingOfWord(utf8String, start, end, misspellingLocation, misspellingLength);
     100            checkSpellingOfWord(string, start, end, misspellingLocation, misspellingLength);
    104101            // Stop checking the next words If the current word is misspelled, to do not overwrite its misspelled location and length.
    105102            if (misspellingLength)
  • trunk/Source/WebCore/platform/text/enchant/TextCheckerEnchant.h

    r175070 r229994  
    4949private:
    5050    void freeEnchantBrokerDictionaries();
    51     void checkSpellingOfWord(const CString&, int start, int end, int& misspellingLocation, int& misspellingLength);
     51    void checkSpellingOfWord(const String&, int start, int end, int& misspellingLocation, int& misspellingLength);
    5252
    5353    EnchantBroker* m_broker;
Note: See TracChangeset for help on using the changeset viewer.