Changeset 223446 in webkit


Ignore:
Timestamp:
Oct 16, 2017 4:29:36 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Allow modern decoding of URLs
https://bugs.webkit.org/show_bug.cgi?id=178265

Patch by Alex Christensen <achristensen@webkit.org> on 2017-10-16
Reviewed by Chris Dumez.

  • platform/URL.h:

(WebCore::URL::decode):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223443 r223446  
     12017-10-16  Alex Christensen  <achristensen@webkit.org>
     2
     3        Allow modern decoding of URLs
     4        https://bugs.webkit.org/show_bug.cgi?id=178265
     5
     6        Reviewed by Chris Dumez.
     7
     8        * platform/URL.h:
     9        (WebCore::URL::decode):
     10
    1112017-10-16  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/Source/WebCore/platform/URL.h

    r222239 r223446  
    206206    template <class Encoder> void encode(Encoder&) const;
    207207    template <class Decoder> static bool decode(Decoder&, URL&);
     208    template <class Decoder> static std::optional<URL> decode(Decoder&);
    208209
    209210    String serialize(bool omitFragment = false) const;
     
    262263bool URL::decode(Decoder& decoder, URL& url)
    263264{
     265    auto optionalURL = URL::decode(decoder);
     266    if (!optionalURL)
     267        return false;
     268    url = WTFMove(*optionalURL);
     269    return true;
     270}
     271
     272template <class Decoder>
     273std::optional<URL> URL::decode(Decoder& decoder)
     274{
     275    URL url;
    264276    if (!decoder.decode(url.m_string))
    265         return false;
     277        return std::nullopt;
    266278    bool isValid;
    267279    if (!decoder.decode(isValid))
    268         return false;
     280        return std::nullopt;
    269281    url.m_isValid = isValid;
    270282    if (!isValid)
    271         return true;
     283        return WTFMove(url);
    272284    bool protocolIsInHTTPFamily;
    273285    if (!decoder.decode(protocolIsInHTTPFamily))
    274         return false;
     286        return std::nullopt;
    275287    url.m_protocolIsInHTTPFamily = protocolIsInHTTPFamily;
    276288    if (!decoder.decode(url.m_schemeEnd))
    277         return false;
     289        return std::nullopt;
    278290    if (!decoder.decode(url.m_userStart))
    279         return false;
     291        return std::nullopt;
    280292    if (!decoder.decode(url.m_userEnd))
    281         return false;
     293        return std::nullopt;
    282294    if (!decoder.decode(url.m_passwordEnd))
    283         return false;
     295        return std::nullopt;
    284296    if (!decoder.decode(url.m_hostEnd))
    285         return false;
     297        return std::nullopt;
    286298    if (!decoder.decode(url.m_portEnd))
    287         return false;
     299        return std::nullopt;
    288300    if (!decoder.decode(url.m_pathAfterLastSlash))
    289         return false;
     301        return std::nullopt;
    290302    if (!decoder.decode(url.m_pathEnd))
    291         return false;
     303        return std::nullopt;
    292304    if (!decoder.decode(url.m_queryEnd))
    293         return false;
    294     return true;
     305        return std::nullopt;
     306    return WTFMove(url);
    295307}
    296308
Note: See TracChangeset for help on using the changeset viewer.