Changeset 80566 in webkit


Ignore:
Timestamp:
Mar 8, 2011 9:41:13 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-03-08 James Kozianski <koz@chromium.org>

Reviewed by David Levin.

Expose isValidProtocol() in KURL.h.
https://bugs.webkit.org/show_bug.cgi?id=54594

This is needed to validate protocols used in calls to
navigator.registerProtocolHandler().

  • platform/KURL.cpp:
  • platform/KURL.h:
  • platform/KURLGoogle.cpp: (WebCore::isValidProtocol):
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r80565 r80566  
     12011-03-08  James Kozianski  <koz@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Expose isValidProtocol() in KURL.h.
     6        https://bugs.webkit.org/show_bug.cgi?id=54594
     7
     8        This is needed to validate protocols used in calls to
     9        navigator.registerProtocolHandler().
     10
     11        * platform/KURL.cpp:
     12        * platform/KURL.h:
     13        * platform/KURLGoogle.cpp:
     14        (WebCore::isValidProtocol):
     15
    1162011-03-08  Adam Roben  <aroben@apple.com>
    217
  • trunk/Source/WebCore/platform/KURL.cpp

    r79956 r80566  
    222222static void encodeRelativeString(const String& rel, const TextEncoding&, CharBuffer& ouput);
    223223static String substituteBackslashes(const String&);
    224 static bool isValidProtocol(const String&);
    225224
    226225static inline bool isSchemeFirstChar(char c) { return characterClassTable[static_cast<unsigned char>(c)] & SchemeFirstChar; }
  • trunk/Source/WebCore/platform/KURL.h

    r79956 r80566  
    280280bool portAllowed(const KURL&); // Blacklist ports that should never be used for Web resources.
    281281
     282bool isValidProtocol(const String&);
     283
    282284String mimeTypeFromDataURL(const String& url);
    283285
  • trunk/Source/WebCore/platform/KURLGoogle.cpp

    r79906 r80566  
    134134}
    135135
     136bool isValidProtocol(const String& protocol)
     137{
     138    // NOTE This is a copy of the function in KURL.cpp.
     139    // RFC3986: ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
     140    if (protocol.isEmpty())
     141        return false;
     142    if (!isSchemeFirstChar(protocol[0]))
     143        return false;
     144    unsigned protocolLength = protocol.length();
     145    for (unsigned i = 1; i < protocolLength; i++) {
     146        if (!isSchemeChar(protocol[i]))
     147            return false;
     148    }
     149    return true;
     150}
     151
    136152
    137153// KURLGooglePrivate -----------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.