Title: [89336] trunk/Source/WebCore
Revision
89336
Author
[email protected]
Date
2011-06-20 23:05:22 -0700 (Mon, 20 Jun 2011)

Log Message

2011-06-20  Andy Estes  <[email protected]>

        Reviewed by Darin Adler.

        KURL::protocolIs(const char* protocol) asserts in Debug builds with
        valid protocols
        https://bugs.webkit.org/show_bug.cgi?id=61572

        No new tests. No code currently calls protocolIs() with a protocol that
        contains a non-letter character.

        * platform/KURL.cpp:
        (WebCore::isSchemeCharacterMatchIgnoringCase): A helper function that
        compares two characters ignoring case. It assumes (and asserts) that
        both characters are valid scheme characters, and that if the second
        argument is a letter that it is lowercase.
        (WebCore::KURL::protocolIs): Call isSchemeCharacterMatchIgnoringCase()
        instead of isLetterMatchIgnoringCase().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89335 => 89336)


--- trunk/Source/WebCore/ChangeLog	2011-06-21 03:57:40 UTC (rev 89335)
+++ trunk/Source/WebCore/ChangeLog	2011-06-21 06:05:22 UTC (rev 89336)
@@ -1,3 +1,22 @@
+2011-06-20  Andy Estes  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        KURL::protocolIs(const char* protocol) asserts in Debug builds with
+        valid protocols
+        https://bugs.webkit.org/show_bug.cgi?id=61572
+
+        No new tests. No code currently calls protocolIs() with a protocol that
+        contains a non-letter character.
+
+        * platform/KURL.cpp:
+        (WebCore::isSchemeCharacterMatchIgnoringCase): A helper function that
+        compares two characters ignoring case. It assumes (and asserts) that
+        both characters are valid scheme characters, and that if the second
+        argument is a letter that it is lowercase.
+        (WebCore::KURL::protocolIs): Call isSchemeCharacterMatchIgnoringCase()
+        instead of isLetterMatchIgnoringCase().
+
 2011-06-20  Dai Mikurube  <[email protected]>
 
         Reviewed by Kent Tamura.

Modified: trunk/Source/WebCore/platform/KURL.cpp (89335 => 89336)


--- trunk/Source/WebCore/platform/KURL.cpp	2011-06-21 03:57:40 UTC (rev 89335)
+++ trunk/Source/WebCore/platform/KURL.cpp	2011-06-21 06:05:22 UTC (rev 89336)
@@ -241,6 +241,14 @@
 static inline bool isPathSegmentEndChar(char c) { return characterClassTable[static_cast<unsigned char>(c)] & PathSegmentEndChar; }
 static inline bool isPathSegmentEndChar(UChar c) { return c <= 0xff && (characterClassTable[c] & PathSegmentEndChar); }
 static inline bool isBadChar(unsigned char c) { return characterClassTable[c] & BadChar; }
+    
+static inline bool isSchemeCharacterMatchIgnoringCase(char character, char schemeCharacter)
+{
+    ASSERT(isSchemeChar(character));
+    ASSERT(schemeCharacter & 0x20);
+    ASSERT(isASCIILower(schemeCharacter) || (!isASCIIUpper(schemeCharacter) && isSchemeChar(schemeCharacter)));
+    return (character | 0x20) == schemeCharacter;
+}
 
 static inline int hexDigitValue(UChar c)
 {
@@ -702,7 +710,7 @@
 
     // Do the comparison without making a new string object.
     for (int i = 0; i < m_schemeEnd; ++i) {
-        if (!protocol[i] || !isLetterMatchIgnoringCase(m_string[i], protocol[i]))
+        if (!protocol[i] || !isSchemeCharacterMatchIgnoringCase(m_string[i], protocol[i]))
             return false;
     }
     return !protocol[m_schemeEnd]; // We should have consumed all characters in the argument.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to