From: ericu@chromium.org Date: Wed, 25 Jan 2012 22:43:19 +0000 (+0000) Subject: Add full support for filesystem URLs. X-Git-Tag: 070512121124~14529 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=551f57ffaceab97304cb8be4e42e8de426b6e6f6;p=profile%2Fivi%2Fwebkit-efl.git Add full support for filesystem URLs. https://bugs.webkit.org/show_bug.cgi?id=75049 Reviewed by Adam Barth. No new tests; existing layout tests cover the basic functionality, and the new functionality won't be there until Chromium adds it. This patch merely enables that, without changing behavior. Source/WebCore: * fileapi/EntryBase.cpp: (WebCore::EntryBase::toURL): Add missing escaping of URL path. * page/SecurityOrigin.cpp: (WebCore::extractInnerURL): Use innerURL member, if it's populated. * platform/KURL.h: (WebCore::KURL::innerURL): Add innerURL member. * platform/KURLGoogle.cpp: (WebCore::KURLGooglePrivate::KURLGooglePrivate): (WebCore::KURLGooglePrivate::operator=): Add copy constructor and operator=, which are now needed since m_innerURL needs special handling. (WebCore::KURLGooglePrivate::setUtf8): (WebCore::KURLGooglePrivate::setAscii): Add calls to initInnerURL. (WebCore::KURLGooglePrivate::initInnerURL): Add method to init/copy m_innerURL. (WebCore::KURLGooglePrivate::copyTo): Handle m_innerURL during copies. (WebCore::encodeWithURLEscapeSequences): Unescape %2F ['/'] in paths; it's much more readable, and it's safe. * platform/KURLGooglePrivate.h: (WebCore::KURLGooglePrivate::innerURL): Add accessor for new m_innerURL. Source/WebKit/chromium: * tests/KURLTest.cpp: TEST(KURLTest, Encode): Update expectation that '/' sails through unescaped. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105930 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ef47fa3..9f55caf 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,41 @@ +2012-01-25 Eric Uhrhane + + Add full support for filesystem URLs. + https://bugs.webkit.org/show_bug.cgi?id=75049 + + Reviewed by Adam Barth. + + No new tests; existing layout tests cover the basic functionality, and + the new functionality won't be there until Chromium adds it. This patch + merely enables that, without changing behavior. + + * fileapi/EntryBase.cpp: + (WebCore::EntryBase::toURL): Add missing escaping of URL path. + + * page/SecurityOrigin.cpp: + (WebCore::extractInnerURL): Use innerURL member, if it's populated. + + * platform/KURL.h: + (WebCore::KURL::innerURL): Add innerURL member. + + * platform/KURLGoogle.cpp: + (WebCore::KURLGooglePrivate::KURLGooglePrivate): + (WebCore::KURLGooglePrivate::operator=): + Add copy constructor and operator=, which are now needed since + m_innerURL needs special handling. + (WebCore::KURLGooglePrivate::setUtf8): + (WebCore::KURLGooglePrivate::setAscii): + Add calls to initInnerURL. + (WebCore::KURLGooglePrivate::initInnerURL): + Add method to init/copy m_innerURL. + (WebCore::KURLGooglePrivate::copyTo): + Handle m_innerURL during copies. + (WebCore::encodeWithURLEscapeSequences): + Unescape %2F ['/'] in paths; it's much more readable, and it's safe. + + * platform/KURLGooglePrivate.h: + (WebCore::KURLGooglePrivate::innerURL): Add accessor for new m_innerURL. + 2012-01-25 Daniel Cheng [chromium] Refactor Clipboard invalidate for DataTransferItem/DataTransferItemList into a wrapper diff --git a/Source/WebCore/fileapi/EntryBase.cpp b/Source/WebCore/fileapi/EntryBase.cpp index 39453f6..53f62e7 100644 --- a/Source/WebCore/fileapi/EntryBase.cpp +++ b/Source/WebCore/fileapi/EntryBase.cpp @@ -75,7 +75,7 @@ String EntryBase::toURL() result.append(DOMFileSystemBase::kExternalPathPrefix); break; } - result.append(m_fullPath); + result.append(encodeWithURLEscapeSequences(m_fullPath)); return result.toString(); } diff --git a/Source/WebCore/page/SecurityOrigin.cpp b/Source/WebCore/page/SecurityOrigin.cpp index 4436694..18e4fa2 100644 --- a/Source/WebCore/page/SecurityOrigin.cpp +++ b/Source/WebCore/page/SecurityOrigin.cpp @@ -82,6 +82,8 @@ static bool shouldUseInnerURL(const KURL& url) // security origin can be parsed using this algorithm. static KURL extractInnerURL(const KURL& url) { + if (url.innerURL()) + return *url.innerURL(); // FIXME: Update this callsite to use the innerURL member function when // we finish implementing it. return KURL(ParsedURLString, decodeURLEscapeSequences(url.path())); diff --git a/Source/WebCore/platform/KURL.h b/Source/WebCore/platform/KURL.h index 8dec81f..3b540eb 100644 --- a/Source/WebCore/platform/KURL.h +++ b/Source/WebCore/platform/KURL.h @@ -26,6 +26,7 @@ #ifndef KURL_h #define KURL_h +#include "NotImplemented.h" #include "PlatformString.h" #include "URLString.h" #include @@ -218,6 +219,13 @@ public: const CString& utf8String() const { return m_url.utf8String(); } #endif + +#if USE(GOOGLEURL) + const KURL* innerURL() const { return m_url.innerURL(); } +#else + const KURL* innerURL() const { notImplemented(); return 0; } +#endif + #ifndef NDEBUG void print() const; #endif diff --git a/Source/WebCore/platform/KURLGoogle.cpp b/Source/WebCore/platform/KURLGoogle.cpp index 6bf9fcc..0507a24 100644 --- a/Source/WebCore/platform/KURLGoogle.cpp +++ b/Source/WebCore/platform/KURLGoogle.cpp @@ -174,6 +174,35 @@ KURLGooglePrivate::KURLGooglePrivate(WTF::HashTableDeletedValueType) { } +KURLGooglePrivate::KURLGooglePrivate(const KURLGooglePrivate& o) + : m_isValid(o.m_isValid) + , m_protocolIsInHTTPFamily(o.m_protocolIsInHTTPFamily) + , m_parsed(o.m_parsed) + , m_utf8(o.m_utf8) + , m_utf8IsASCII(o.m_utf8IsASCII) + , m_stringIsValid(o.m_stringIsValid) + , m_string(o.m_string) +{ + if (o.m_innerURL.get()) + m_innerURL = adoptPtr(new KURL(o.m_innerURL->copy())); +} + +KURLGooglePrivate& KURLGooglePrivate::operator=(const KURLGooglePrivate& o) +{ + m_isValid = o.m_isValid; + m_protocolIsInHTTPFamily = o.m_protocolIsInHTTPFamily; + m_parsed = o.m_parsed; + m_utf8 = o.m_utf8; + m_utf8IsASCII = o.m_utf8IsASCII; + m_stringIsValid = o.m_stringIsValid; + m_string = o.m_string; + if (o.m_innerURL.get()) + m_innerURL = adoptPtr(new KURL(o.m_innerURL->copy())); + else + m_innerURL.clear(); + return *this; +} + // Setters for the data. Using the ASCII version when you know the // data is ASCII will be slightly more efficient. The UTF-8 version // will always be correct if the caller is unsure. @@ -197,6 +226,7 @@ void KURLGooglePrivate::setUtf8(const CString& str) m_utf8 = str; m_stringIsValid = false; initProtocolIsInHTTPFamily(); + initInnerURL(); } void KURLGooglePrivate::setAscii(const CString& str) @@ -205,6 +235,7 @@ void KURLGooglePrivate::setAscii(const CString& str) m_utf8IsASCII = true; m_stringIsValid = false; initProtocolIsInHTTPFamily(); + initInnerURL(); } void KURLGooglePrivate::init(const KURL& base, @@ -258,6 +289,21 @@ void KURLGooglePrivate::init(const KURL& base, const CHAR* rel, int relLength, } } +void KURLGooglePrivate::initInnerURL() +{ + if (!m_isValid) { + m_innerURL.clear(); + return; + } + url_parse::Parsed* innerParsed = m_parsed.inner_parsed(); + if (innerParsed) + m_innerURL = adoptPtr(new KURL( + ParsedURLString, + String(m_utf8.data() + innerParsed->scheme.begin, innerParsed->Length() - innerParsed->scheme.begin))); + else + m_innerURL.clear(); +} + void KURLGooglePrivate::initProtocolIsInHTTPFamily() { if (!m_isValid) { @@ -285,6 +331,10 @@ void KURLGooglePrivate::copyTo(KURLGooglePrivate* dest) const dest->m_utf8IsASCII = m_utf8IsASCII; dest->m_stringIsValid = false; dest->m_string = String(); // Clear the invalid string to avoid cross thread ref counting. + if (m_innerURL) + dest->m_innerURL = adoptPtr(new KURL(m_innerURL->copy())); + else + dest->m_innerURL.clear(); } String KURLGooglePrivate::componentString(const url_parse::Component& comp) const @@ -827,7 +877,10 @@ String encodeWithURLEscapeSequences(const String& notEncodedString) buffer.Resize(inputLength * 3); url_util::EncodeURIComponent(input, inputLength, &buffer); - return String(buffer.data(), buffer.length()); + String escaped(buffer.data(), buffer.length()); + // Unescape '/'; it's safe and much prettier. + escaped.replace("%2F", "/"); + return escaped; } bool KURL::isHierarchical() const diff --git a/Source/WebCore/platform/KURLGooglePrivate.h b/Source/WebCore/platform/KURLGooglePrivate.h index 31efd64..374d0d7 100644 --- a/Source/WebCore/platform/KURLGooglePrivate.h +++ b/Source/WebCore/platform/KURLGooglePrivate.h @@ -31,6 +31,7 @@ #ifndef KURLGooglePrivate_h #define KURLGooglePrivate_h +#include #include #include @@ -49,6 +50,8 @@ namespace WebCore { KURLGooglePrivate(); KURLGooglePrivate(const url_parse::Parsed&, bool isValid); KURLGooglePrivate(WTF::HashTableDeletedValueType); + KURLGooglePrivate(const KURLGooglePrivate&); + KURLGooglePrivate& operator=(const KURLGooglePrivate&); // Initializes the object. This will call through the backend initializer // below. @@ -94,7 +97,10 @@ namespace WebCore { bool m_protocolIsInHTTPFamily; url_parse::Parsed m_parsed; // Indexes into the UTF-8 version of the string. + KURL* innerURL() const { return m_innerURL.get(); } + private: + void initInnerURL(); void initProtocolIsInHTTPFamily(); CString m_utf8; @@ -107,6 +113,8 @@ namespace WebCore { mutable bool m_stringIsValid; mutable String m_string; + + OwnPtr m_innerURL; }; } // namespace WebCore diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index e6c6659..7e49af1 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,17 @@ +2012-01-25 Eric Uhrhane + + Add full support for filesystem URLs. + https://bugs.webkit.org/show_bug.cgi?id=75049 + + Reviewed by Adam Barth. + + No new tests; existing layout tests cover the basic functionality, and + the new functionality won't be there until Chromium adds it. This patch + merely enables that, without changing behavior. + + * tests/KURLTest.cpp: + TEST(KURLTest, Encode): Update expectation that '/' sails through unescaped. + 2012-01-25 Joshua Bell IndexedDB: Need to distinguish key paths that don't yield value vs. yield invalid key diff --git a/Source/WebKit/chromium/tests/KURLTest.cpp b/Source/WebKit/chromium/tests/KURLTest.cpp index f2abda5..394c664 100644 --- a/Source/WebKit/chromium/tests/KURLTest.cpp +++ b/Source/WebKit/chromium/tests/KURLTest.cpp @@ -316,7 +316,7 @@ TEST(KURLTest, Encode) {"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", "%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F"}, {" !\"#$%&'()*+,-./", - "%20!%22%23%24%25%26'()*%2B%2C-.%2F"}, + "%20!%22%23%24%25%26'()*%2B%2C-./"}, {"0123456789:;<=>?", "0123456789%3A%3B%3C%3D%3E%3F"}, {"@ABCDEFGHIJKLMNO",