Title: [220799] trunk
Revision
220799
Author
[email protected]
Date
2017-08-16 10:30:39 -0700 (Wed, 16 Aug 2017)

Log Message

EventSource: ignore IDs with U+0000
https://bugs.webkit.org/show_bug.cgi?id=175178

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Import WPT test coverage from:
- https://github.com/w3c/web-platform-tests/pull/6584

* web-platform-tests/eventsource/format-field-id-null-expected.txt: Added.
* web-platform-tests/eventsource/format-field-id-null.htm: Added.
* web-platform-tests/eventsource/resources/last-event-id.py:
(main):
* web-platform-tests/eventsource/w3c-import.log:

Source/WebCore:

EventSource: ignore IDs with U+0000 as per:
https://github.com/whatwg/html/pull/2849

Test: imported/w3c/web-platform-tests/eventsource/format-field-id-null.htm

* page/EventSource.cpp:
(WebCore::EventSource::parseEventStreamLine):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (220798 => 220799)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-08-16 16:46:15 UTC (rev 220798)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-08-16 17:30:39 UTC (rev 220799)
@@ -1,3 +1,19 @@
+2017-08-16  Chris Dumez  <[email protected]>
+
+        EventSource: ignore IDs with U+0000
+        https://bugs.webkit.org/show_bug.cgi?id=175178
+
+        Reviewed by Darin Adler.
+
+        Import WPT test coverage from:
+        - https://github.com/w3c/web-platform-tests/pull/6584
+
+        * web-platform-tests/eventsource/format-field-id-null-expected.txt: Added.
+        * web-platform-tests/eventsource/format-field-id-null.htm: Added.
+        * web-platform-tests/eventsource/resources/last-event-id.py:
+        (main):
+        * web-platform-tests/eventsource/w3c-import.log:
+
 2017-08-15  Andy Estes  <[email protected]>
 
         [Payment Request] Import test suite from web-platform-tests

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null-expected.txt (0 => 220799)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null-expected.txt	2017-08-16 17:30:39 UTC (rev 220799)
@@ -0,0 +1,3 @@
+
+PASS EventSource: U+0000 in id field 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null.htm (0 => 220799)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null.htm	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null.htm	2017-08-16 17:30:39 UTC (rev 220799)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>EventSource: U+0000 in id field</title>
+    <script src=""
+    <script src=""
+  </head>
+  <body>
+    <div id="log"></div>
+    <script>
+      var test = async_test()
+      test.step(function() {
+        var source = new EventSource("resources/last-event-id.py?idvalue=%00%00"),
+            seenhello = false
+        source._onmessage_ = function(e) {
+          test.step(function() {
+            if(e.data == "hello" && !seenhello) {
+              seenhello = true
+              assert_equals(e.lastEventId, "")
+            } else if(seenhello) {
+              assert_equals(e.data, "hello")
+              assert_equals(e.lastEventId, "")
+              source.close()
+              test.done()
+            } else
+              assert_unreached()
+          })
+        }
+      })
+    </script>
+  </body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/resources/last-event-id.py (220798 => 220799)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/resources/last-event-id.py	2017-08-16 16:46:15 UTC (rev 220798)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/resources/last-event-id.py	2017-08-16 17:30:39 UTC (rev 220799)
@@ -3,9 +3,10 @@
 def main(request, response):
   response.headers.set("Content-Type", "text/event-stream")
   last_event_id = request.headers.get('Last-Event-ID', None)
+  value = request.GET.first("idvalue", "…")
 
   if(last_event_id):
       return "data: " + last_event_id + "\n\n"
   else:
-    return "id: …\nretry: 200\ndata: hello\n\n"
+    return "id: " + value + "\nretry: 200\ndata: hello\n\n"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/w3c-import.log (220798 => 220799)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/w3c-import.log	2017-08-16 16:46:15 UTC (rev 220798)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/eventsource/w3c-import.log	2017-08-16 17:30:39 UTC (rev 220799)
@@ -42,6 +42,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-event-empty.htm
 /LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-event.htm
 /LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-2.htm
+/LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id-null.htm
 /LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-id.htm
 /LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-parsing.htm
 /LayoutTests/imported/w3c/web-platform-tests/eventsource/format-field-retry-bogus.htm

Modified: trunk/Source/WebCore/ChangeLog (220798 => 220799)


--- trunk/Source/WebCore/ChangeLog	2017-08-16 16:46:15 UTC (rev 220798)
+++ trunk/Source/WebCore/ChangeLog	2017-08-16 17:30:39 UTC (rev 220799)
@@ -1,3 +1,18 @@
+2017-08-16  Chris Dumez  <[email protected]>
+
+        EventSource: ignore IDs with U+0000
+        https://bugs.webkit.org/show_bug.cgi?id=175178
+
+        Reviewed by Darin Adler.
+
+        EventSource: ignore IDs with U+0000 as per:
+        https://github.com/whatwg/html/pull/2849
+
+        Test: imported/w3c/web-platform-tests/eventsource/format-field-id-null.htm
+
+        * page/EventSource.cpp:
+        (WebCore::EventSource::parseEventStreamLine):
+
 2017-08-16  Fujii Hironori  <[email protected]>
 
         [HarfBuzz] Decomposed Vietnamese characters are rendered incorrectly

Modified: trunk/Source/WebCore/page/EventSource.cpp (220798 => 220799)


--- trunk/Source/WebCore/page/EventSource.cpp	2017-08-16 16:46:15 UTC (rev 220798)
+++ trunk/Source/WebCore/page/EventSource.cpp	2017-08-16 17:30:39 UTC (rev 220799)
@@ -345,9 +345,11 @@
         m_data.append('\n');
     } else if (field == "event")
         m_eventName = { &m_receiveBuffer[position], valueLength };
-    else if (field == "id")
-        m_currentlyParsedEventId = { &m_receiveBuffer[position], valueLength };
-    else if (field == "retry") {
+    else if (field == "id") {
+        StringView parsedEventId = { &m_receiveBuffer[position], valueLength };
+        if (!parsedEventId.contains('\0'))
+            m_currentlyParsedEventId = parsedEventId.toString();
+    } else if (field == "retry") {
         if (!valueLength)
             m_reconnectDelay = defaultReconnectDelay;
         else {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to