diff options
| author | Steve Block <steveblock@google.com> | 2012-03-27 18:40:26 +0100 | 
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2012-03-28 16:54:59 +0100 | 
| commit | e48d279609693b4d164199748c93ad791547c649 (patch) | |
| tree | 25780dbbd84520d51c0fd174a299121e0d46f5e2 | |
| parent | c57e584da242d96ba18578a71f4634adc9d1fff6 (diff) | |
| download | external_webkit-e48d279609693b4d164199748c93ad791547c649.zip external_webkit-e48d279609693b4d164199748c93ad791547c649.tar.gz external_webkit-e48d279609693b4d164199748c93ad791547c649.tar.bz2 | |
Cherry-pick WebKit change r96779 to fix window.location
See http://trac.webkit.org/changeset/96779
Note that a conflict occurred in Source/WebCore/platform/qt/KURLQt.cpp but the
change is not required.
Bug: 2159848
Change-Id: I56e645b2f187302c6f1858c8c6c291209f130cad
19 files changed, 49 insertions, 43 deletions
| diff --git a/LayoutTests/fast/url/file-http-base-expected.txt b/LayoutTests/fast/url/file-http-base-expected.txt index afd3131..f9169cd 100644 --- a/LayoutTests/fast/url/file-http-base-expected.txt +++ b/LayoutTests/fast/url/file-http-base-expected.txt @@ -20,7 +20,8 @@ PASS canonicalize('file:///foo/bar.txt') is 'file:///foo/bar.txt'  FAIL canonicalize('FILE:/\\/\\7:\\\\//foo\\bar.html') should be file://7:////foo/bar.html. Was file:////7:////foo/bar.html.  PASS canonicalize('file:filer/home\\me') is 'file://filer/home/me'  FAIL canonicalize('file:///C:/foo/../../../bar.html') should be file:///C:/bar.html. Was file:///bar.html. -FAIL canonicalize('file:///C:/asdf#\xc2') should be file:///C:/asdf#�. Was file:///C:/asdf#%C2. +FAIL canonicalize('file:///C:/asdf#\xc2') should be file:///C:/asdf#Â. Was file:///C:/asdf#%C2. +FAIL canonicalize('file:///C:/asdf#Â') should be file:///C:/asdf#Â. Was file:///C:/asdf#%C2.  PASS canonicalize('file:///home/me') is 'file:///home/me'  FAIL canonicalize('file:c:\\foo\\bar.html') should be file:///c:/foo/bar.html. Was file://c:/foo/bar.html.  FAIL canonicalize('file:c|//foo\\bar.html') should be file:///c%7C//foo/bar.html. Was file://c|//foo/bar.html. diff --git a/LayoutTests/fast/url/mailto-expected.txt b/LayoutTests/fast/url/mailto-expected.txt index cd318f9..dc49e91 100644 --- a/LayoutTests/fast/url/mailto-expected.txt +++ b/LayoutTests/fast/url/mailto-expected.txt @@ -8,7 +8,7 @@ PASS canonicalize('mailto:addr1@foo.com') is 'mailto:addr1@foo.com'  PASS canonicalize('mailto:addr1 	 ') is 'mailto:addr1'  PASS canonicalize('mailto:addr1?to=jon') is 'mailto:addr1?to=jon'  PASS canonicalize('mailto:addr1,addr2') is 'mailto:addr1,addr2' -FAIL canonicalize('mailto:addr1, addr2') should be mailto:addr1, addr2. Was mailto:addr1,%20addr2. +PASS canonicalize('mailto:addr1, addr2') is 'mailto:addr1, addr2'  PASS canonicalize('mailto:addr1%2caddr2') is 'mailto:addr1%2caddr2'  PASS canonicalize('mailto:𐌀') is 'mailto:%F0%90%8C%80'  PASS canonicalize('mailto:addr1?') is 'mailto:addr1?' diff --git a/LayoutTests/fast/url/script-tests/file-http-base.js b/LayoutTests/fast/url/script-tests/file-http-base.js index ca9e734..00965b8 100644 --- a/LayoutTests/fast/url/script-tests/file-http-base.js +++ b/LayoutTests/fast/url/script-tests/file-http-base.js @@ -36,7 +36,8 @@ cases = [      // Make sure relative paths can't go above the "C:"      ["file:///C:/foo/../../../bar.html", "file:///C:/bar.html"],      // Busted refs shouldn't make the whole thing fail. -    ["file:///C:/asdf#\\xc2", "file:///C:/asdf#\\xef\\xbf\\xbd"], +    ["file:///C:/asdf#\\xc2", "file:///C:/asdf#\\xc2"], +    ["file:///C:/asdf#\xc2", "file:///C:/asdf#\xc2"],      // Unix-style paths      ["file:///home/me", "file:///home/me"], diff --git a/LayoutTests/fast/url/script-tests/segments.js b/LayoutTests/fast/url/script-tests/segments.js index a1e5dba..a83cb61 100644 --- a/LayoutTests/fast/url/script-tests/segments.js +++ b/LayoutTests/fast/url/script-tests/segments.js @@ -1,6 +1,6 @@  description("Test URL segmentation"); -cases = [  +cases = [    // [URL, [SCHEME, HOST, PORT, PATH, QUERY, REF]]    ["http://user:pass@foo:21/bar;par?b#c",    ["http:","foo","21","/bar;par","?b","#c"]],    ["http:foo.com",                           ["http:","example.org","","/foo/foo.com","",""]], @@ -91,7 +91,14 @@ cases = [    ["wss:example.com/",                       ["wss:","example.com","","/","",""]],    ["data:example.com/",                      ["data:","","","example.com/","",""]],    ["javascript:example.com/",                ["javascript:","","","example.com/","",""]], -  ["mailto:example.com/",                    ["mailto:","","","example.com/","",""]],   +  ["mailto:example.com/",                    ["mailto:","","","example.com/","",""]], + +  ["/a/b/c",                                  ["http:","example.org","","/a/b/c","",""]], +  ["/a/ /c",                                  ["http:","example.org","","/a/%20/c","",""]], +  ["/a%2fc",                                  ["http:","example.org","","/a%2fc","",""]], +  ["/a/%2f/c",                                ["http:","example.org","","/a/%2f/c","",""]], + +  ["#\u03B2",                                 ["http:","example.org","","/foo/bar","","#\u03B2"]],  ];  var originalBaseURL = canonicalize("."); diff --git a/LayoutTests/fast/url/script-tests/standard-url.js b/LayoutTests/fast/url/script-tests/standard-url.js index 27afe76..5611faa 100644 --- a/LayoutTests/fast/url/script-tests/standard-url.js +++ b/LayoutTests/fast/url/script-tests/standard-url.js @@ -1,8 +1,10 @@  description("Canonicalization of standard URLs"); -cases = [  +cases = [    ["http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#"], +  ["http://www.google.com/foo?bar=baz# \u00bb", "http://www.google.com/foo?bar=baz# \u00bb"],    ["http://[www.google.com]/", "http://[www.google.com]/"], +  ["http://www.google.com", "http://www.google.com/"],    // Disabled because whitespace gets treated different in this API.    // ["ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#"],    ["http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo"], @@ -58,6 +60,9 @@ cases = [    ["data:example.com/", "data:example.com/"],    ["javascript:example.com/", "javascript:example.com/"],    ["mailto:example.com/", "mailto:example.com/"], +  // Escaping of non hierarchical URLs +  ["javascript:alert(\\t 1 \\n\\r)", "javascript:alert( 1 )"], +  ['javascript:alert(" \1 \u03B2 ")', 'javascript:alert(" %01 %CE%B2 ")'],  ];  for (var i = 0; i < cases.length; ++i) { diff --git a/LayoutTests/fast/url/segments-expected.txt b/LayoutTests/fast/url/segments-expected.txt index 0e51a1a..76e49aa 100644 --- a/LayoutTests/fast/url/segments-expected.txt +++ b/LayoutTests/fast/url/segments-expected.txt @@ -8,7 +8,7 @@ PASS segments('http:foo.com') is '["http:","example.org","","/foo/foo.com","",""  PASS segments('\t   :foo.com   \n') is '["http:","example.org","","/foo/:foo.com","",""]'  PASS segments(' foo.com  ') is '["http:","example.org","","/foo/foo.com","",""]'  PASS segments('a:\t foo.com') is '["a:","",""," foo.com","",""]' -FAIL segments('http://f:21/ b ? d # e ') should be ["http:","f","21","/%20b%20","?%20d%20","# e"]. Was ["http:","f","21","/ b ","?%20d%20","# e"]. +PASS segments('http://f:21/ b ? d # e ') is '["http:","f","21","/%20b%20","?%20d%20","# e"]'  PASS segments('http://f:/c') is '["http:","f","","/c","",""]'  PASS segments('http://f:0/c') is '["http:","f","0","/c","",""]'  PASS segments('http://f:00000000000000/c') is '["http:","f","0","/c","",""]' @@ -93,6 +93,11 @@ PASS segments('wss:example.com/') is '["wss:","example.com","","/","",""]'  PASS segments('data:example.com/') is '["data:","","","example.com/","",""]'  PASS segments('javascript:example.com/') is '["javascript:","","","example.com/","",""]'  PASS segments('mailto:example.com/') is '["mailto:","","","example.com/","",""]' +PASS segments('/a/b/c') is '["http:","example.org","","/a/b/c","",""]' +PASS segments('/a/ /c') is '["http:","example.org","","/a/%20/c","",""]' +PASS segments('/a%2fc') is '["http:","example.org","","/a%2fc","",""]' +PASS segments('/a/%2f/c') is '["http:","example.org","","/a/%2f/c","",""]' +FAIL segments('#β') should be ["http:","example.org","","/foo/bar","","#β"]. Was ["http:","example.org","","/foo/bar","","#%CE%B2"].  PASS successfullyParsed is true  TEST COMPLETE diff --git a/LayoutTests/fast/url/segments-from-data-url-expected.txt b/LayoutTests/fast/url/segments-from-data-url-expected.txt index b4195a4..c64aefc 100644 --- a/LayoutTests/fast/url/segments-from-data-url-expected.txt +++ b/LayoutTests/fast/url/segments-from-data-url-expected.txt @@ -8,7 +8,7 @@ PASS segments('http:foo.com') is '["http:","foo.com","","/","",""]'  PASS segments('\t   :foo.com   \n') is '[":","","","","",""]'  PASS segments(' foo.com  ') is '[":","","","","",""]'  PASS segments('a:\t foo.com') is '["a:","",""," foo.com","",""]' -FAIL segments('http://f:21/ b ? d # e ') should be ["http:","f","21","/%20b%20","?%20d%20","# e"]. Was ["http:","f","21","/ b ","?%20d%20","# e"]. +PASS segments('http://f:21/ b ? d # e ') is '["http:","f","21","/%20b%20","?%20d%20","# e"]'  PASS segments('http://f:/c') is '["http:","f","","/c","",""]'  PASS segments('http://f:0/c') is '["http:","f","0","/c","",""]'  PASS segments('http://f:00000000000000/c') is '["http:","f","0","/c","",""]' diff --git a/LayoutTests/fast/url/segments.html b/LayoutTests/fast/url/segments.html index 5cc2f82..96aa871 100644 --- a/LayoutTests/fast/url/segments.html +++ b/LayoutTests/fast/url/segments.html @@ -1,6 +1,7 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!DOCTYPE html>  <html>  <head> +<meta charset="utf-8">  <link rel="stylesheet" href="../js/resources/js-test-style.css">  <script src="../js/resources/js-test-pre.js"></script>  <script src="resources/utilities.js"></script> diff --git a/LayoutTests/fast/url/standard-url-expected.txt b/LayoutTests/fast/url/standard-url-expected.txt index 99ba8bb..d274059 100644 --- a/LayoutTests/fast/url/standard-url-expected.txt +++ b/LayoutTests/fast/url/standard-url-expected.txt @@ -4,7 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE  PASS canonicalize('http://www.google.com/foo?bar=baz#') is 'http://www.google.com/foo?bar=baz#' +FAIL canonicalize('http://www.google.com/foo?bar=baz# »') should be http://www.google.com/foo?bar=baz# ». Was http://www.google.com/foo?bar=baz# %BB.  PASS canonicalize('http://[www.google.com]/') is 'http://[www.google.com]/' +PASS canonicalize('http://www.google.com') is 'http://www.google.com/'  FAIL canonicalize('http:////////user:@google.com:99?foo') should be http://user@google.com:99/?foo. Was http://////user:@google.com:99?foo.  FAIL canonicalize('http://192.0x00A80001') should be http://192.168.0.1/. Was http://192.0x00A80001/.  FAIL canonicalize('http://www/foo%2Ehtml') should be http://www/foo.html. Was http://www/foo%2Ehtml. @@ -53,6 +55,8 @@ PASS canonicalize('wss:example.com/') is 'wss://example.com/'  PASS canonicalize('data:example.com/') is 'data:example.com/'  PASS canonicalize('javascript:example.com/') is 'javascript:example.com/'  PASS canonicalize('mailto:example.com/') is 'mailto:example.com/' +PASS canonicalize('javascript:alert(\t 1 \n\r)') is 'javascript:alert( 1 )' +PASS canonicalize('javascript:alert("  β ")') is 'javascript:alert(" %01 %CE%B2 ")'  PASS successfullyParsed is true  TEST COMPLETE diff --git a/Source/WebCore/fileapi/DOMFileSystemBase.cpp b/Source/WebCore/fileapi/DOMFileSystemBase.cpp index eafb815..5a2627f 100644 --- a/Source/WebCore/fileapi/DOMFileSystemBase.cpp +++ b/Source/WebCore/fileapi/DOMFileSystemBase.cpp @@ -63,7 +63,7 @@ bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, AsyncFileSystem::Typ          return false;      KURL originURL(ParsedURLString, url.path()); -    String path = originURL.path(); +    String path = decodeURLEscapeSequences(originURL.path());      if (path.isEmpty() || path[0] != '/')          return false;      path = path.substring(1); diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp index f999fdb..670cf1f 100644 --- a/Source/WebCore/loader/FrameLoader.cpp +++ b/Source/WebCore/loader/FrameLoader.cpp @@ -993,7 +993,8 @@ void FrameLoader::loadArchive(PassRefPtr<Archive> prpArchive)  ObjectContentType FrameLoader::defaultObjectContentType(const KURL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages)  {      String mimeType = mimeTypeIn; -    String extension = url.path().substring(url.path().reverseFind('.') + 1); +    String decodedPath = decodeURLEscapeSequences(url.path()); +    String extension = decodedPath.substring(decodedPath.reverseFind('.') + 1);      // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure      if (mimeType.isEmpty()) diff --git a/Source/WebCore/page/Location.cpp b/Source/WebCore/page/Location.cpp index 9528437..fb68a09 100644 --- a/Source/WebCore/page/Location.cpp +++ b/Source/WebCore/page/Location.cpp @@ -63,9 +63,7 @@ String Location::href() const      if (!m_frame)          return String(); -    const KURL& url = this->url(); -    // FIXME: Stop using deprecatedString(): https://bugs.webkit.org/show_bug.cgi?id=30225 -    return url.hasPath() ? url.deprecatedString() : url.deprecatedString() + "/"; +    return url().string();  }  String Location::protocol() const @@ -148,16 +146,6 @@ String Location::getParameter(const String& name) const      return parameters.get(name);  } -String Location::toString() const -{ -    if (!m_frame) -        return String(); - -    const KURL& url = this->url(); -    // FIXME: Stop using deprecatedString(): https://bugs.webkit.org/show_bug.cgi?id=30225 -    return url.hasPath() ? url.deprecatedString() : url.deprecatedString() + "/"; -} -  void Location::setHref(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow)  {      if (!m_frame) diff --git a/Source/WebCore/page/Location.h b/Source/WebCore/page/Location.h index 1b68cee..0e89ecf 100644 --- a/Source/WebCore/page/Location.h +++ b/Source/WebCore/page/Location.h @@ -29,9 +29,9 @@  #ifndef Location_h  #define Location_h -#include <wtf/Forward.h>  #include <wtf/PassRefPtr.h>  #include <wtf/RefCounted.h> +#include <wtf/text/WTFString.h>  namespace WebCore { @@ -71,7 +71,7 @@ public:      String hash() const;      String origin() const; -    String toString() const; +    String toString() const { return href(); }      String getParameter(const String&) const; diff --git a/Source/WebCore/platform/KURL.cpp b/Source/WebCore/platform/KURL.cpp index 7c952a2..234d749 100644 --- a/Source/WebCore/platform/KURL.cpp +++ b/Source/WebCore/platform/KURL.cpp @@ -708,7 +708,7 @@ String KURL::query() const  String KURL::path() const  { -    return decodeURLEscapeSequences(m_string.substring(m_portEnd, m_pathEnd - m_portEnd));  +    return m_string.substring(m_portEnd, m_pathEnd - m_portEnd);  }  bool KURL::setProtocol(const String& s) @@ -996,7 +996,7 @@ static void appendEscapingBadChars(char*& buffer, const char* strStart, size_t l      buffer = p;  } -static void escapeAndAppendFragment(char*& buffer, const char* strStart, size_t length) +static void escapeAndAppendNonHierarchicalPart(char*& buffer, const char* strStart, size_t length)  {      char* p = buffer; @@ -1420,7 +1420,9 @@ void KURL::parse(const char* url, const String* originalString)          *p++ = '/';      // add path, escaping bad characters -    if (!hierarchical || !hasSlashDotOrDotDot(url)) +    if (!hierarchical) +        escapeAndAppendNonHierarchicalPart(p, url + pathStart, pathEnd - pathStart); +    else if (!hasSlashDotOrDotDot(url))          appendEscapingBadChars(p, url + pathStart, pathEnd - pathStart);      else {          CharBuffer pathBuffer(pathEnd - pathStart + 1); @@ -1446,7 +1448,7 @@ void KURL::parse(const char* url, const String* originalString)      // add fragment, escaping bad characters      if (fragmentEnd != queryEnd) {          *p++ = '#'; -        escapeAndAppendFragment(p, url + fragmentStart, fragmentEnd - fragmentStart); +        escapeAndAppendNonHierarchicalPart(p, url + fragmentStart, fragmentEnd - fragmentStart);      }      m_fragmentEnd = p - buffer.data(); diff --git a/Source/WebCore/platform/KURLGoogle.cpp b/Source/WebCore/platform/KURLGoogle.cpp index 7bb1d53..54bcf16 100644 --- a/Source/WebCore/platform/KURLGoogle.cpp +++ b/Source/WebCore/platform/KURLGoogle.cpp @@ -593,7 +593,6 @@ String KURL::query() const  String KURL::path() const  { -    // Note: KURL.cpp unescapes here.      return m_url.componentString(m_url.m_parsed.path);  } diff --git a/Source/WebCore/platform/qt/KURLQt.cpp b/Source/WebCore/platform/qt/KURLQt.cpp index f6d2a86..674a933 100644 --- a/Source/WebCore/platform/qt/KURLQt.cpp +++ b/Source/WebCore/platform/qt/KURLQt.cpp @@ -50,4 +50,3 @@ String KURL::fileSystemPath() const  }  } - diff --git a/Source/WebCore/platform/win/ClipboardWin.cpp b/Source/WebCore/platform/win/ClipboardWin.cpp index 0b5a3d3..2e56cbc 100644 --- a/Source/WebCore/platform/win/ClipboardWin.cpp +++ b/Source/WebCore/platform/win/ClipboardWin.cpp @@ -191,7 +191,7 @@ static HGLOBAL createGlobalHDropContent(const KURL& url, String& fileName, Share      WCHAR filePath[MAX_PATH];      if (url.isLocalFile()) { -        String localPath = url.path(); +        String localPath = decodeURLEscapeSequences(url.path());          // windows does not enjoy a leading slash on paths          if (localPath[0] == '/')              localPath = localPath.substring(1); diff --git a/Source/WebCore/workers/WorkerLocation.cpp b/Source/WebCore/workers/WorkerLocation.cpp index 33aebbb..319a528 100644 --- a/Source/WebCore/workers/WorkerLocation.cpp +++ b/Source/WebCore/workers/WorkerLocation.cpp @@ -36,8 +36,7 @@ namespace WebCore {  String WorkerLocation::href() const  { -    // FIXME: Stop using deprecatedString(): https://bugs.webkit.org/show_bug.cgi?id=30225 -    return m_url.hasPath() ? m_url.deprecatedString() : m_url.deprecatedString() + "/"; +    return m_url.string();  }  String WorkerLocation::protocol() const @@ -75,12 +74,6 @@ String WorkerLocation::hash() const      return m_url.fragmentIdentifier().isEmpty() ? "" : "#" + m_url.fragmentIdentifier();  } -String WorkerLocation::toString() const -{ -    // FIXME: Stop using deprecatedString(): https://bugs.webkit.org/show_bug.cgi?id=30225 -    return m_url.hasPath() ? m_url.deprecatedString() : m_url.deprecatedString() + "/"; -} -  } // namespace WebCore diff --git a/Source/WebCore/workers/WorkerLocation.h b/Source/WebCore/workers/WorkerLocation.h index 5200e35..692c0e3 100644 --- a/Source/WebCore/workers/WorkerLocation.h +++ b/Source/WebCore/workers/WorkerLocation.h @@ -30,10 +30,10 @@  #if ENABLE(WORKERS)  #include "KURL.h" -#include <wtf/Forward.h>  #include <wtf/PassRefPtr.h>  #include <wtf/RefCounted.h>  #include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h>  namespace WebCore { @@ -57,7 +57,7 @@ namespace WebCore {          String search() const;          String hash() const; -        String toString() const; +        String toString() const { return href(); }      private:          WorkerLocation(const KURL& url) : m_url(url) { } | 
