Title: [116601] trunk
Revision
116601
Author
[email protected]
Date
2012-05-09 20:30:48 -0700 (Wed, 09 May 2012)

Log Message

[BlackBerry] Cookie parsing issue. If the cookie value provided was (") then the browser creates a session cookie instead.
https://bugs.webkit.org/show_bug.cgi?id=85775

Patch by Jason Liu <[email protected]> on 2012-05-09
Reviewed by Rob Buis.

Source/WebCore:

Make CookieParser::parseOneCookie handle (cookiename="cookievalue;expires=xxxx) correctly.
This cookie's value is "cookievalue not "cookievalue;expires=xxxx.

Test: http/tests/cookies/single-quoted-value.html

* platform/blackberry/CookieParser.cpp:
(WebCore::CookieParser::parseOneCookie):

LayoutTests:

* http/tests/cookies/script-tests/single-quoted-value.js: Added.
* http/tests/cookies/single-quoted-value-expected.txt: Added.
* http/tests/cookies/single-quoted-value.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116600 => 116601)


--- trunk/LayoutTests/ChangeLog	2012-05-10 03:24:40 UTC (rev 116600)
+++ trunk/LayoutTests/ChangeLog	2012-05-10 03:30:48 UTC (rev 116601)
@@ -1,3 +1,14 @@
+2012-05-09  Jason Liu  <[email protected]>
+
+        [BlackBerry] Cookie parsing issue. If the cookie value provided was (") then the browser creates a session cookie instead.
+        https://bugs.webkit.org/show_bug.cgi?id=85775
+
+        Reviewed by Rob Buis.
+
+        * http/tests/cookies/script-tests/single-quoted-value.js: Added.
+        * http/tests/cookies/single-quoted-value-expected.txt: Added.
+        * http/tests/cookies/single-quoted-value.html: Added.
+
 2012-05-09  Hayato Ito  <[email protected]>
 
         Remove unused test expectation files.

Added: trunk/LayoutTests/http/tests/cookies/script-tests/single-quoted-value.js (0 => 116601)


--- trunk/LayoutTests/http/tests/cookies/script-tests/single-quoted-value.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/script-tests/single-quoted-value.js	2012-05-10 03:30:48 UTC (rev 116601)
@@ -0,0 +1,11 @@
+description(
+'Test for &lt;<a href="" [BlackBerry] Cookie parsing issue. If the cookie value provided was (") then the browser creates a session cookie instead.'
+);
+
+clearAllCookies();
+
+debug("Check that setting a cookie with a single-quoted value works.");
+cookiesShouldBe('singleQuoted="value;Version=1;Path=/', 'singleQuoted="value');
+clearCookies();
+
+successfullyParsed = true;

Added: trunk/LayoutTests/http/tests/cookies/single-quoted-value-expected.txt (0 => 116601)


--- trunk/LayoutTests/http/tests/cookies/single-quoted-value-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/single-quoted-value-expected.txt	2012-05-10 03:30:48 UTC (rev 116601)
@@ -0,0 +1,11 @@
+Test for <https://bugs.webkit.org/show_bug.cgi?id=85775> [BlackBerry] Cookie parsing issue. If the cookie value provided was (") then the browser creates a session cookie instead.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Check that setting a cookie with a single-quoted value works.
+PASS cookie is 'singleQuoted="value'.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/cookies/single-quoted-value.html (0 => 116601)


--- trunk/LayoutTests/http/tests/cookies/single-quoted-value.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cookies/single-quoted-value.html	2012-05-10 03:30:48 UTC (rev 116601)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (116600 => 116601)


--- trunk/Source/WebCore/ChangeLog	2012-05-10 03:24:40 UTC (rev 116600)
+++ trunk/Source/WebCore/ChangeLog	2012-05-10 03:30:48 UTC (rev 116601)
@@ -1,3 +1,18 @@
+2012-05-09  Jason Liu  <[email protected]>
+
+        [BlackBerry] Cookie parsing issue. If the cookie value provided was (") then the browser creates a session cookie instead.
+        https://bugs.webkit.org/show_bug.cgi?id=85775
+
+        Reviewed by Rob Buis.
+
+        Make CookieParser::parseOneCookie handle (cookiename="cookievalue;expires=xxxx) correctly.
+        This cookie's value is "cookievalue not "cookievalue;expires=xxxx.
+
+        Test: http/tests/cookies/single-quoted-value.html
+
+        * platform/blackberry/CookieParser.cpp:
+        (WebCore::CookieParser::parseOneCookie):
+
 2012-05-09  Raymond Liu  <[email protected]>
 
         Add multi-channels support for CopyWithGainFrom in AudioBus

Modified: trunk/Source/WebCore/platform/blackberry/CookieParser.cpp (116600 => 116601)


--- trunk/Source/WebCore/platform/blackberry/CookieParser.cpp	2012-05-10 03:24:40 UTC (rev 116600)
+++ trunk/Source/WebCore/platform/blackberry/CookieParser.cpp	2012-05-10 03:30:48 UTC (rev 116601)
@@ -109,16 +109,21 @@
     unsigned tokenEnd = start; // Token end contains the position of the '=' or the end of a token
     unsigned pairEnd = start; // Pair end contains always the position of the ';'
 
-    // find the *first* ';' and the '=' (if they exist)
-    bool quoteFound = false;
+    // Find the first ';' which is not double-quoted and the '=' (if they exist).
     bool foundEqual = false;
-    while (pairEnd < end && (cookie[pairEnd] != ';' || quoteFound)) {
-        if (tokenEnd == start && cookie[pairEnd] == '=') {
-            tokenEnd = pairEnd;
-            foundEqual = true;
+    while (pairEnd < end && cookie[pairEnd] != ';') {
+        if (cookie[pairEnd] == '=') {
+            if (tokenEnd == start) {
+                tokenEnd = pairEnd;
+                foundEqual = true;
+            }
+        } else if (cookie[pairEnd] == '"') {
+            size_t secondQuotePosition = cookie.find('"', pairEnd + 1);
+            if (secondQuotePosition != notFound && secondQuotePosition <= end) {
+                pairEnd = secondQuotePosition + 1;
+                continue;
+            }
         }
-        if (cookie[pairEnd] == '"')
-            quoteFound = !quoteFound;
         pairEnd++;
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to