Title: [161269] trunk
Revision
161269
Author
[email protected]
Date
2014-01-03 10:59:58 -0800 (Fri, 03 Jan 2014)

Log Message

Line ending conversion should be able to handle strings with null chars
https://bugs.webkit.org/show_bug.cgi?id=126202

This is a merge from Blink.

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Test: http/tests/local/formdata/send-form-data-with-string-containing-null.html

* platform/text/LineEnding.cpp: (WebCore::normalizeToCROrLF): Do it right.

LayoutTests:

* http/tests/local/formdata/send-form-data-with-string-containing-null-expected.txt: Added.
* http/tests/local/formdata/send-form-data-with-string-containing-null.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (161268 => 161269)


--- trunk/LayoutTests/ChangeLog	2014-01-03 18:49:25 UTC (rev 161268)
+++ trunk/LayoutTests/ChangeLog	2014-01-03 18:59:58 UTC (rev 161269)
@@ -1,3 +1,15 @@
+2014-01-03  Alexey Proskuryakov  <[email protected]>
+
+        Line ending conversion should be able to handle strings with null chars
+        https://bugs.webkit.org/show_bug.cgi?id=126202
+
+        This is a merge from Blink.
+
+        Reviewed by Alexey Proskuryakov.
+
+        * http/tests/local/formdata/send-form-data-with-string-containing-null-expected.txt: Added.
+        * http/tests/local/formdata/send-form-data-with-string-containing-null.html: Added.
+
 2014-01-03  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-string-containing-null-expected.txt (0 => 161269)


--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-string-containing-null-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-string-containing-null-expected.txt	2014-01-03 18:59:58 UTC (rev 161269)
@@ -0,0 +1,10 @@
+Test that we can send textarea data containing null characters.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS the string containing a null byte is echoed correctly.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-string-containing-null.html (0 => 161269)


--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-string-containing-null.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-string-containing-null.html	2014-01-03 18:59:58 UTC (rev 161269)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test that we can send textarea data containing null characters.");
+
+function runTest()
+{
+    // We can't use testSendingFormData because PHP escapes
+    // null bytes on Windows.
+    var xhr = new XMLHttpRequest();
+    xhr.open('POST', 'http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi', false);
+    var formData = new FormData();
+    formData.append('textarea', 'hello\u0000world');
+    xhr.send(formData);
+    if (xhr.readyState !== 4 || xhr.status !== 200) {
+        testFailed('xhr.readyState = ' + xhr.readyState + ', xhr.status = ' + xhr.status);
+        return;
+    }
+    if (xhr.response.indexOf('name="textarea"\r\n\r\nhello\u0000world') >= 0) {
+        testPassed('the string containing a null byte is echoed correctly.');
+    } else {
+        testFailed('the string containing a null byte is not echoed correctly.');
+    }
+}
+
+if (window.eventSender) {
+    runTest();
+} else {
+    testFailed("This test is not interactive, please run in a testing environment.");
+}
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (161268 => 161269)


--- trunk/Source/WebCore/ChangeLog	2014-01-03 18:49:25 UTC (rev 161268)
+++ trunk/Source/WebCore/ChangeLog	2014-01-03 18:59:58 UTC (rev 161269)
@@ -1,3 +1,16 @@
+2014-01-03  Alexey Proskuryakov  <[email protected]>
+
+        Line ending conversion should be able to handle strings with null chars
+        https://bugs.webkit.org/show_bug.cgi?id=126202
+
+        This is a merge from Blink.
+
+        Reviewed by Alexey Proskuryakov.
+
+        Test: http/tests/local/formdata/send-form-data-with-string-containing-null.html
+
+        * platform/text/LineEnding.cpp: (WebCore::normalizeToCROrLF): Do it right.
+
 2014-01-03  Alberto Garcia  <[email protected]>
 
         WebKit-GTK 1.8.1 does not build on OS X 10.7

Modified: trunk/Source/WebCore/platform/text/LineEnding.cpp (161268 => 161269)


--- trunk/Source/WebCore/platform/text/LineEnding.cpp	2014-01-03 18:49:25 UTC (rev 161268)
+++ trunk/Source/WebCore/platform/text/LineEnding.cpp	2014-01-03 18:59:58 UTC (rev 161269)
@@ -101,7 +101,8 @@
     // Compute the new length.
     size_t newLen = 0;
     const char* p = from.data();
-    while (char c = *p++) {
+    while (p < from.data() + from.length()) {
+        char c = *p++;
         if (c == '\r') {
             // Safe to look ahead because of trailing '\0'.
             if (*p != '\n') {
@@ -128,7 +129,8 @@
     char* q = buffer.allocate(newLen);
 
     // Make a copy of the string.
-    while (char c = *p++) {
+    while (p < from.data() + from.length()) {
+        char c = *p++;
         if (c == '\r') {
             // Safe to look ahead because of trailing '\0'.
             if (*p != '\n') {
@@ -162,7 +164,8 @@
     const char* p = from.data();
     char fromEndingChar = toCR ? '\n' : '\r';
     char toEndingChar = toCR ? '\r' : '\n';
-    while (char c = *p++) {
+    while (p < from.data() + from.length()) {
+        char c = *p++;
         if (c == '\r' && *p == '\n') {
             // Turn CRLF into CR or LF.
             p++;
@@ -187,7 +190,8 @@
     }
 
     // Make a copy of the string.
-    while (char c = *p++) {
+    while (p < from.data() + from.length()) {
+        char c = *p++;
         if (c == '\r' && *p == '\n') {
             // Turn CRLF or CR into CR or LF.
             p++;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to