Title: [195913] trunk
Revision
195913
Author
[email protected]
Date
2016-01-30 14:25:21 -0800 (Sat, 30 Jan 2016)

Log Message

Modern IDB: Some tests crash with specific odd database names.
https://bugs.webkit.org/show_bug.cgi?id=153688

Reviewed by Darin Adler.

Source/WebCore:

No new tests (2 existing tests now pass).

* platform/FileSystem.cpp:
(WebCore::shouldEscapeUChar): Return true for some surrogate-pair situations.
(WebCore::encodeForFileName): Pass along the previous and next characters, as well,
  and do a two byte escaping for some characters.

LayoutTests:

* platform/mac-wk1/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (195912 => 195913)


--- trunk/LayoutTests/ChangeLog	2016-01-30 22:19:08 UTC (rev 195912)
+++ trunk/LayoutTests/ChangeLog	2016-01-30 22:25:21 UTC (rev 195913)
@@ -1,3 +1,12 @@
+2016-01-30  Brady Eidson  <[email protected]>
+
+        Modern IDB: Some tests crash with specific odd database names.
+        https://bugs.webkit.org/show_bug.cgi?id=153688
+
+        Reviewed by Darin Adler.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-01-30  Eric Carlson  <[email protected]>
 
         More than one audio and/or text track sometimes selected in media controls menu

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (195912 => 195913)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-30 22:19:08 UTC (rev 195912)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2016-01-30 22:25:21 UTC (rev 195913)
@@ -271,9 +271,7 @@
 storage/indexeddb/transaction-coordination-within-database.html [ Skip ]
 
 # SQLite backend tests that crash or ASSERT
-storage/indexeddb/database-odd-names.html [ Skip ]
 storage/indexeddb/dont-wedge.html [ Skip ]
-storage/indexeddb/odd-strings.html [ Skip ]
 
 ### END OF (3) IndexedDB failures with SQLite
 ########################################

Modified: trunk/Source/WebCore/ChangeLog (195912 => 195913)


--- trunk/Source/WebCore/ChangeLog	2016-01-30 22:19:08 UTC (rev 195912)
+++ trunk/Source/WebCore/ChangeLog	2016-01-30 22:25:21 UTC (rev 195913)
@@ -1,3 +1,17 @@
+2016-01-30  Brady Eidson  <[email protected]>
+
+        Modern IDB: Some tests crash with specific odd database names.
+        https://bugs.webkit.org/show_bug.cgi?id=153688
+
+        Reviewed by Darin Adler.
+
+        No new tests (2 existing tests now pass).
+
+        * platform/FileSystem.cpp:
+        (WebCore::shouldEscapeUChar): Return true for some surrogate-pair situations.
+        (WebCore::encodeForFileName): Pass along the previous and next characters, as well,
+          and do a two byte escaping for some characters.
+
 2016-01-30  Eric Carlson  <[email protected]>
 
         More than one audio and/or text track sometimes selected in media controls menu

Modified: trunk/Source/WebCore/platform/FileSystem.cpp (195912 => 195913)


--- trunk/Source/WebCore/platform/FileSystem.cpp	2016-01-30 22:19:08 UTC (rev 195912)
+++ trunk/Source/WebCore/platform/FileSystem.cpp	2016-01-30 22:25:21 UTC (rev 195913)
@@ -82,21 +82,46 @@
     /* 78-7F */ false, false, false, false, true,  false, false, true, 
 };
 
-static inline bool shouldEscapeUChar(UChar c)
+static inline bool shouldEscapeUChar(UChar character, UChar previousCharacter, UChar nextCharacter)
 {
-    return c > 127 ? false : needsEscaping[c];
+    if (character <= 127)
+        return needsEscaping[character];
+
+    if (U16_IS_LEAD(character) && !U16_IS_TRAIL(nextCharacter))
+        return true;
+
+    if (U16_IS_TRAIL(character) && !U16_IS_LEAD(previousCharacter))
+        return true;
+
+    return false;
 }
 
 String encodeForFileName(const String& inputString)
 {
+    unsigned length = inputString.length();
+    if (!length)
+        return inputString;
+
     StringBuilder result;
-    StringImpl* stringImpl = inputString.impl();
-    unsigned length = inputString.length();
+    result.reserveCapacity(length);
+
+    UChar previousCharacter;
+    UChar character = 0;
+    UChar nextCharacter = inputString[0];
     for (unsigned i = 0; i < length; ++i) {
-        UChar character = (*stringImpl)[i];
-        if (shouldEscapeUChar(character)) {
-            result.append('%');
-            appendByteAsHex(character, result);
+        previousCharacter = character;
+        character = nextCharacter;
+        nextCharacter = i + 1 < length ? inputString[i + 1] : 0;
+
+        if (shouldEscapeUChar(character, previousCharacter, nextCharacter)) {
+            if (character <= 255) {
+                result.append('%');
+                appendByteAsHex(character, result);
+            } else {
+                result.appendLiteral("%+");
+                appendByteAsHex(character >> 8, result);
+                appendByteAsHex(character, result);
+            }
         } else
             result.append(character);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to