Skip to content

Commit

Permalink
Add full support for filesystem URLs.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Eric Uhrhane committed Jan 25, 2012
1 parent 61074c7 commit 006bd69
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 3 deletions.
38 changes: 38 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,41 @@
2012-01-25 Eric Uhrhane <ericu@chromium.org>

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 <dcheng@chromium.org>

[chromium] Refactor Clipboard invalidate for DataTransferItem/DataTransferItemList into a wrapper
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/fileapi/EntryBase.cpp
Expand Up @@ -75,7 +75,7 @@ String EntryBase::toURL()
result.append(DOMFileSystemBase::kExternalPathPrefix);
break;
}
result.append(m_fullPath);
result.append(encodeWithURLEscapeSequences(m_fullPath));
return result.toString();
}

Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/page/SecurityOrigin.cpp
Expand Up @@ -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()));
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/platform/KURL.h
Expand Up @@ -26,6 +26,7 @@
#ifndef KURL_h
#define KURL_h

#include "NotImplemented.h"
#include "PlatformString.h"
#include "URLString.h"
#include <wtf/HashMap.h>
Expand Down Expand Up @@ -218,6 +219,13 @@ class KURL {
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
Expand Down
55 changes: 54 additions & 1 deletion Source/WebCore/platform/KURLGoogle.cpp
Expand Up @@ -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.
Expand All @@ -197,6 +226,7 @@ void KURLGooglePrivate::setUtf8(const CString& str)
m_utf8 = str;
m_stringIsValid = false;
initProtocolIsInHTTPFamily();
initInnerURL();
}

void KURLGooglePrivate::setAscii(const CString& str)
Expand All @@ -205,6 +235,7 @@ void KURLGooglePrivate::setAscii(const CString& str)
m_utf8IsASCII = true;
m_stringIsValid = false;
initProtocolIsInHTTPFamily();
initInnerURL();
}

void KURLGooglePrivate::init(const KURL& base,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Source/WebCore/platform/KURLGooglePrivate.h
Expand Up @@ -31,6 +31,7 @@
#ifndef KURLGooglePrivate_h
#define KURLGooglePrivate_h

#include <wtf/OwnPtr.h>
#include <wtf/text/CString.h>

#include <googleurl/src/url_parse.h>
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -107,6 +113,8 @@ namespace WebCore {

mutable bool m_stringIsValid;
mutable String m_string;

OwnPtr<KURL> m_innerURL;
};

} // namespace WebCore
Expand Down
14 changes: 14 additions & 0 deletions Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,17 @@
2012-01-25 Eric Uhrhane <ericu@chromium.org>

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 <jsbell@chromium.org>

IndexedDB: Need to distinguish key paths that don't yield value vs. yield invalid key
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/chromium/tests/KURLTest.cpp
Expand Up @@ -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",
Expand Down

0 comments on commit 006bd69

Please sign in to comment.