[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

abarth at webkit.org abarth at webkit.org
Wed Dec 22 14:37:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6a7b5b0c2ebed3fa5ad76c0ec2374dafe2f6fb6f
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 14 08:02:13 2010 +0000

    2010-10-13  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Implement getParameter from the URL API
            https://bugs.webkit.org/show_bug.cgi?id=46610
    
            Test various interesting cases in parameter parsing.
    
            * fast/dom/anchor-getParameter-expected.txt: Added.
            * fast/dom/anchor-getParameter.html: Added.
            * http/tests/misc/location-getParameter-expected.txt: Added.
            * http/tests/misc/location-getParameter.html: Added.
    2010-10-13  Adam Barth  <abarth at webkit.org>
    
            Reviewed by Darin Adler.
    
            Implement getParameter from the URL API
            https://bugs.webkit.org/show_bug.cgi?id=46610
    
            Another API from
            https://docs.google.com/document/edit?id=1r_VTFKApVOaNIkocrg0z-t7lZgzisTuGTXkdzAk4gLU&hl=en#
            getParameter lets a web site easily read the value of a URL parameter.
            This API is for the simple case of a non-repeated parameter name.
            getParameterAll will handle repeated parameter names in a future patch.
    
            Tests: fast/dom/anchor-getParameter.html
                   http/tests/misc/location-getParameter.html
    
            * html/HTMLAnchorElement.cpp:
            (WebCore::HTMLAnchorElement::getParameter):
            * html/HTMLAnchorElement.h:
            * html/HTMLAnchorElement.idl:
            * page/Location.cpp:
            (WebCore::Location::getParameter):
            * page/Location.h:
            * page/Location.idl:
            * platform/KURL.cpp:
            (WebCore::KURL::copyParsedQueryTo):
            * platform/KURLGoogle.cpp:
            (WebCore::KURL::copyParsedQueryTo):
            * platform/KURL.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69749 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a5c2f18..3247658 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-10-13  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Implement getParameter from the URL API
+        https://bugs.webkit.org/show_bug.cgi?id=46610
+
+        Test various interesting cases in parameter parsing.
+
+        * fast/dom/anchor-getParameter-expected.txt: Added.
+        * fast/dom/anchor-getParameter.html: Added.
+        * http/tests/misc/location-getParameter-expected.txt: Added.
+        * http/tests/misc/location-getParameter.html: Added.
+
 2010-10-14  Adrienne Walker  <enne at google.com>
 
         Reviewed by James Robinson.
diff --git a/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt b/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt
index 8506efa..9fdcb92 100644
--- a/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt
@@ -5,6 +5,7 @@ PASS history.length == "LEFTOVER" is false
 PASS history.pushState == "LEFTOVER" is false
 PASS history.replaceState == "LEFTOVER" is false
 PASS location.assign == "LEFTOVER" is false
+PASS location.getParameter == "LEFTOVER" is false
 PASS location.hash == "LEFTOVER" is false
 PASS location.host == "LEFTOVER" is false
 PASS location.hostname == "LEFTOVER" is false
diff --git a/LayoutTests/fast/dom/Window/window-properties-expected.txt b/LayoutTests/fast/dom/Window/window-properties-expected.txt
index 911dc4b..96d69d4 100644
--- a/LayoutTests/fast/dom/Window/window-properties-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-properties-expected.txt
@@ -2268,6 +2268,7 @@ window.length [number]
 window.localStorage [printed above as window.Storage.prototype]
 window.location [object Location]
 window.location.assign [function]
+window.location.getParameter [function]
 window.location.hash [string]
 window.location.host [string]
 window.location.hostname [string]
diff --git a/LayoutTests/fast/dom/anchor-getParameter-expected.txt b/LayoutTests/fast/dom/anchor-getParameter-expected.txt
new file mode 100644
index 0000000..6f0253f
--- /dev/null
+++ b/LayoutTests/fast/dom/anchor-getParameter-expected.txt
@@ -0,0 +1,20 @@
+http://example.com/foo/bar?a=b (a) => b
+http://example.com/foo/bar?abc=xy (abc) => xy
+http://example.com/foo/bar?a=x&b=y (a) => x
+http://example.com/foo/bar?a=x&b=y (b) => y
+http://example.com/foo/bar?a=x&a=y (a) => y
+http://example.com/foo/bar?a=x&a=y&a=z (a) => z
+http://example.com/foo/bar?a=x&A=y&a=z (A) => y
+http://example.com/foo/bar?121= (121) => 
+http://example.com/foo/bar?a& (a) => 
+http://example.com/foo/bar?a (a) => 
+http://example.com/foo/bar?=a& (a) => 
+http://example.com/foo/bar?a=b=c (a) => b=c
+http://example.com/foo/bar?a=b=c (b) => 
+http://example.com/foo/bar?a=b=& (a) => b=
+http://example.com/foo/bar?a=b=& (b) => 
+http://example.com/foo/bar?&a=b (a) => b
+http://example.com/foo/bar?&a=b& (a) => b
+http://example.com/foo/bar?a=b#xyz (a) => b
+http://example.com/foo/bar?#a=b%23xyz (a) => 
+
diff --git a/LayoutTests/fast/dom/anchor-getParameter.html b/LayoutTests/fast/dom/anchor-getParameter.html
new file mode 100644
index 0000000..42d5d88
--- /dev/null
+++ b/LayoutTests/fast/dom/anchor-getParameter.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+var cases = [
+    ["http://example.com/foo/bar?a=b", 'a'],
+    ["http://example.com/foo/bar?abc=xy", 'abc'],
+    ["http://example.com/foo/bar?a=x&b=y", 'a'],
+    ["http://example.com/foo/bar?a=x&b=y", 'b'],
+    ["http://example.com/foo/bar?a=x&a=y", 'a'],
+    ["http://example.com/foo/bar?a=x&a=y&a=z", 'a'],
+    ["http://example.com/foo/bar?a=x&A=y&a=z", 'A'],
+    ["http://example.com/foo/bar?121=", '121'],
+    ["http://example.com/foo/bar?a&", 'a'],
+    ["http://example.com/foo/bar?a", 'a'],
+    ["http://example.com/foo/bar?=a&", 'a'],
+    ["http://example.com/foo/bar?a=b=c", 'a'],
+    ["http://example.com/foo/bar?a=b=c", 'b'],
+    ["http://example.com/foo/bar?a=b=&", 'a'],
+    ["http://example.com/foo/bar?a=b=&", 'b'],
+    ["http://example.com/foo/bar?&a=b", 'a'],
+    ["http://example.com/foo/bar?&a=b&", 'a'],
+    ["http://example.com/foo/bar?a=b#xyz", 'a'],
+    ["http://example.com/foo/bar?#a=b#xyz", 'a']
+];
+
+document.write('<div style="display:none">');
+for (var i = 0; i < cases.length; ++i)
+    document.write('<a href="' + cases[i][0] + '">Link</a><br>');
+document.write('</div>');
+
+var elmts = document.getElementsByTagName('a');
+for (var i = 0; i < elmts.length; ++i)
+    document.write(elmts[i].href + ' (' + cases[i][1] + ') => ' + elmts[i].getParameter(cases[i][1]) + '<br>');
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/misc/location-getParameter-expected.txt b/LayoutTests/http/tests/misc/location-getParameter-expected.txt
new file mode 100644
index 0000000..12a4b56
--- /dev/null
+++ b/LayoutTests/http/tests/misc/location-getParameter-expected.txt
@@ -0,0 +1,4 @@
+
+b
+d
+
diff --git a/LayoutTests/http/tests/misc/location-getParameter.html b/LayoutTests/http/tests/misc/location-getParameter.html
new file mode 100644
index 0000000..dbfe7a1
--- /dev/null
+++ b/LayoutTests/http/tests/misc/location-getParameter.html
@@ -0,0 +1,16 @@
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+if (top === self) {
+    document.write('<iframe src="'+ location + '?a=b&c=d#ttt"></iframe>');
+
+    window.onload = function() {
+        document.getElementById('results').innerHTML = 
+        frames[0].location.getParameter('a') + '<br>' +
+        frames[0].location.getParameter('c') + '<br>' +
+        frames[0].location.getParameter('d');
+    }
+}
+</script>
+<div id="results"></div>
diff --git a/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt b/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt
index e972f36..02194bc 100644
--- a/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt
+++ b/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt
@@ -20,6 +20,8 @@ CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http
 
 CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
 
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-enumeration.html. Domains, protocols and ports must match.
+
 This tests that variable names can't be enumerated cross domain (see http://bugs.webkit.org/show_bug.cgi?id=16387)
 
 
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b654457..7123ee0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-10-13  Adam Barth  <abarth at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Implement getParameter from the URL API
+        https://bugs.webkit.org/show_bug.cgi?id=46610
+
+        Another API from
+        https://docs.google.com/document/edit?id=1r_VTFKApVOaNIkocrg0z-t7lZgzisTuGTXkdzAk4gLU&hl=en#
+        getParameter lets a web site easily read the value of a URL parameter.
+        This API is for the simple case of a non-repeated parameter name.
+        getParameterAll will handle repeated parameter names in a future patch.
+
+        Tests: fast/dom/anchor-getParameter.html
+               http/tests/misc/location-getParameter.html
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::getParameter):
+        * html/HTMLAnchorElement.h:
+        * html/HTMLAnchorElement.idl:
+        * page/Location.cpp:
+        (WebCore::Location::getParameter):
+        * page/Location.h:
+        * page/Location.idl:
+        * platform/KURL.cpp:
+        (WebCore::KURL::copyParsedQueryTo):
+        * platform/KURLGoogle.cpp:
+        (WebCore::KURL::copyParsedQueryTo):
+        * platform/KURL.h:
+
 2010-10-14  Alejandro G. Castro  <alex at igalia.com>
 
         Unreviewed. GTK build fix.
diff --git a/WebCore/html/HTMLAnchorElement.cpp b/WebCore/html/HTMLAnchorElement.cpp
index 2274f65..7f52c6f 100644
--- a/WebCore/html/HTMLAnchorElement.cpp
+++ b/WebCore/html/HTMLAnchorElement.cpp
@@ -449,6 +449,13 @@ String HTMLAnchorElement::origin() const
     return origin->toString();
 }
 
+String HTMLAnchorElement::getParameter(const String& name) const
+{
+    ParsedURLParameters parameters;
+    href().copyParsedQueryTo(parameters);
+    return parameters.get(name);
+}
+
 void HTMLAnchorElement::setSearch(const String& value)
 {
     KURL url = href();
diff --git a/WebCore/html/HTMLAnchorElement.h b/WebCore/html/HTMLAnchorElement.h
index a7e7eec..71837ca 100644
--- a/WebCore/html/HTMLAnchorElement.h
+++ b/WebCore/html/HTMLAnchorElement.h
@@ -84,6 +84,8 @@ public:
 
     String origin() const;
 
+    String getParameter(const String&) const;
+
     String text() const;
 
     String toString() const;
diff --git a/WebCore/html/HTMLAnchorElement.idl b/WebCore/html/HTMLAnchorElement.idl
index c918fde..432df69 100644
--- a/WebCore/html/HTMLAnchorElement.idl
+++ b/WebCore/html/HTMLAnchorElement.idl
@@ -53,6 +53,8 @@ module html {
         readonly attribute [ConvertNullToNullString] DOMString origin;
 #endif
 
+        DOMString getParameter(in DOMString name);
+
         readonly attribute DOMString text;
 
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
diff --git a/WebCore/page/Location.cpp b/WebCore/page/Location.cpp
index c02304c..78809e3 100644
--- a/WebCore/page/Location.cpp
+++ b/WebCore/page/Location.cpp
@@ -138,6 +138,16 @@ String Location::hash() const
     return fragmentIdentifier.isEmpty() ? "" : "#" + fragmentIdentifier;
 }
 
+String Location::getParameter(const String& name) const
+{
+    if (!m_frame)
+        return String();
+
+    ParsedURLParameters parameters;
+    url().copyParsedQueryTo(parameters);
+    return parameters.get(name);
+}
+
 String Location::toString() const
 {
     if (!m_frame)
diff --git a/WebCore/page/Location.h b/WebCore/page/Location.h
index a4bc407..c62f5aa 100644
--- a/WebCore/page/Location.h
+++ b/WebCore/page/Location.h
@@ -59,6 +59,8 @@ namespace WebCore {
 
         String toString() const;
 
+        String getParameter(const String&) const;
+
     private:
         Location(Frame*);
 
diff --git a/WebCore/page/Location.idl b/WebCore/page/Location.idl
index 1668e05..76340d9 100644
--- a/WebCore/page/Location.idl
+++ b/WebCore/page/Location.idl
@@ -62,6 +62,8 @@ module window {
                  readonly attribute DOMString origin;
 #endif
 
+        DOMString getParameter(in DOMString name);
+
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
         [DontEnum, Custom, V8OnInstance, V8ReadOnly] DOMString toString();
 #endif
diff --git a/WebCore/platform/KURL.cpp b/WebCore/platform/KURL.cpp
index 16b84b5..3ac5d86 100644
--- a/WebCore/platform/KURL.cpp
+++ b/WebCore/platform/KURL.cpp
@@ -616,6 +616,33 @@ bool KURL::hasFragmentIdentifier() const
     return m_fragmentEnd != m_queryEnd;
 }
 
+void KURL::copyParsedQueryTo(ParsedURLParameters& parameters) const
+{
+    const UChar* pos = m_string.characters() + m_pathEnd + 1;
+    const UChar* end = m_string.characters() + m_queryEnd;
+    while (pos < end) {
+        const UChar* parameterStart = pos;
+        while (pos < end && *pos != '&')
+            ++pos;
+        const UChar* parameterEnd = pos;
+        if (pos < end) {
+            ASSERT(*pos == '&');
+            ++pos;
+        }
+        if (parameterStart == parameterEnd)
+            continue;
+        const UChar* nameStart = parameterStart;
+        const UChar* equalSign = parameterStart;
+        while (equalSign < parameterEnd && *equalSign != '=')
+            ++equalSign;
+        if (equalSign == nameStart)
+            continue;
+        String name(nameStart, equalSign - nameStart);
+        String value = equalSign == parameterEnd ? String() : String(equalSign + 1, parameterEnd - equalSign - 1);
+        parameters.set(name, value);
+    }
+}
+
 String KURL::baseAsString() const
 {
     return m_string.left(m_pathAfterLastSlash);
diff --git a/WebCore/platform/KURL.h b/WebCore/platform/KURL.h
index aca1aba..cbf0d8b 100644
--- a/WebCore/platform/KURL.h
+++ b/WebCore/platform/KURL.h
@@ -27,6 +27,7 @@
 #define KURL_h
 
 #include "PlatformString.h"
+#include <wtf/HashMap.h>
 
 #if PLATFORM(CF)
 typedef const struct __CFURL* CFURLRef;
@@ -59,6 +60,8 @@ namespace WebCore {
 class TextEncoding;
 struct KURLHash;
 
+typedef HashMap<String, String> ParsedURLParameters;
+
 enum ParsedURLStringTag { ParsedURLString };
 
 class KURL {
@@ -133,6 +136,8 @@ public:
     String fragmentIdentifier() const;
     bool hasFragmentIdentifier() const;
 
+    void copyParsedQueryTo(ParsedURLParameters&) const;
+
     String baseAsString() const;
 
     String prettyURL() const;
diff --git a/WebCore/platform/KURLGoogle.cpp b/WebCore/platform/KURLGoogle.cpp
index 3d23fcf..726bc57 100644
--- a/WebCore/platform/KURLGoogle.cpp
+++ b/WebCore/platform/KURLGoogle.cpp
@@ -549,6 +549,34 @@ bool KURL::hasFragmentIdentifier() const
     return m_url.m_parsed.ref.len >= 0;
 }
 
+void KURL::copyParsedQueryTo(ParsedURLParameters& parameters) const
+{
+    String query = m_url.componentString(m_url.m_parsed.query);
+    const UChar* pos = query.characters();
+    const UChar* end = query.characters() + query.length();
+    while (pos < end) {
+        const UChar* parameterStart = pos;
+        while (pos < end && *pos != '&')
+            ++pos;
+        const UChar* parameterEnd = pos;
+        if (pos < end) {
+            ASSERT(*pos == '&');
+            ++pos;
+        }
+        if (parameterStart == parameterEnd)
+            continue;
+        const UChar* nameStart = parameterStart;
+        const UChar* equalSign = parameterStart;
+        while (equalSign < parameterEnd && *equalSign != '=')
+            ++equalSign;
+        if (equalSign == nameStart)
+            continue;
+        String name(nameStart, equalSign - nameStart);
+        String value = equalSign == parameterEnd ? String() : String(equalSign + 1, parameterEnd - equalSign - 1);
+        parameters.set(name, value);
+    }
+}
+
 String KURL::baseAsString() const
 {
     // FIXME: There is probably a more efficient way to do this?

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list