Title: [202910] trunk
- Revision
- 202910
- Author
- [email protected]
- Date
- 2016-07-07 09:24:14 -0700 (Thu, 07 Jul 2016)
Log Message
[Fetch API] Response constructor should throw in case of bad reason phrase
https://bugs.webkit.org/show_bug.cgi?id=159508
Patch by Youenn Fablet <[email protected]> on 2016-07-07
Reviewed by Alex Christensen.
LayoutTests/imported/w3c:
* web-platform-tests/fetch/api/response/response-error-expected.txt:
Source/WebCore:
Covered by rebased test.
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::initializeWith): Validating reason phrase with new routine.
Throwing a TypeError in case of error.
* platform/network/HTTPParsers.cpp:
(WebCore::isValidReasonPhrase): Added to validate reason phrase according
https://tools.ietf.org/html/rfc7230#section-3.1.2
* platform/network/HTTPParsers.h:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (202909 => 202910)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-07-07 16:03:18 UTC (rev 202909)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-07-07 16:24:14 UTC (rev 202910)
@@ -1,5 +1,14 @@
2016-07-07 Youenn Fablet <[email protected]>
+ [Fetch API] Response constructor should throw in case of bad reason phrase
+ https://bugs.webkit.org/show_bug.cgi?id=159508
+
+ Reviewed by Alex Christensen.
+
+ * web-platform-tests/fetch/api/response/response-error-expected.txt:
+
+2016-07-07 Youenn Fablet <[email protected]>
+
[Fetch API] Response.redirect should throw a RangeError in case of bad status code
https://bugs.webkit.org/show_bug.cgi?id=159507
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error-expected.txt (202909 => 202910)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error-expected.txt 2016-07-07 16:03:18 UTC (rev 202909)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-error-expected.txt 2016-07-07 16:24:14 UTC (rev 202910)
@@ -4,10 +4,9 @@
PASS Throws RangeError when responseInit's status is 199
PASS Throws RangeError when responseInit's status is 600
PASS Throws RangeError when responseInit's status is 1000
-FAIL Throws TypeError when responseInit's statusText is
- assert_throws: Expect TypeError exception
- function "function () { new Response("", { "statusText" : statusTex..." did not throw
-FAIL Throws TypeError when responseInit's statusText is Ā assert_throws: Expect TypeError exception Ā function "function () { new Response("", { "statusText" : statusTex..." did not throw
+PASS Throws TypeError when responseInit's statusText is
+
+PASS Throws TypeError when responseInit's statusText is Ā
PASS Throws TypeError when building a response with body and a body status of 204
PASS Throws TypeError when building a response with body and a body status of 205
PASS Throws TypeError when building a response with body and a body status of 304
Modified: trunk/Source/WebCore/ChangeLog (202909 => 202910)
--- trunk/Source/WebCore/ChangeLog 2016-07-07 16:03:18 UTC (rev 202909)
+++ trunk/Source/WebCore/ChangeLog 2016-07-07 16:24:14 UTC (rev 202910)
@@ -1,5 +1,22 @@
2016-07-07 Youenn Fablet <[email protected]>
+ [Fetch API] Response constructor should throw in case of bad reason phrase
+ https://bugs.webkit.org/show_bug.cgi?id=159508
+
+ Reviewed by Alex Christensen.
+
+ Covered by rebased test.
+
+ * Modules/fetch/FetchResponse.cpp:
+ (WebCore::FetchResponse::initializeWith): Validating reason phrase with new routine.
+ Throwing a TypeError in case of error.
+ * platform/network/HTTPParsers.cpp:
+ (WebCore::isValidReasonPhrase): Added to validate reason phrase according
+ https://tools.ietf.org/html/rfc7230#section-3.1.2
+ * platform/network/HTTPParsers.h:
+
+2016-07-07 Youenn Fablet <[email protected]>
+
[Fetch API] Response.redirect should throw a RangeError in case of bad status code
https://bugs.webkit.org/show_bug.cgi?id=159507
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (202909 => 202910)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2016-07-07 16:03:18 UTC (rev 202909)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2016-07-07 16:24:14 UTC (rev 202910)
@@ -34,6 +34,7 @@
#include "Dictionary.h"
#include "ExceptionCode.h"
#include "FetchRequest.h"
+#include "HTTPParsers.h"
#include "JSFetchResponse.h"
#include "ScriptExecutionContext.h"
@@ -86,9 +87,8 @@
return;
}
- // FIXME: Validate reason phrase (https://tools.ietf.org/html/rfc7230#section-3.1.2).
String statusText;
- if (!init.get("statusText", statusText)) {
+ if (!init.get("statusText", statusText) || !isValidReasonPhrase(statusText)) {
ec = TypeError;
return;
}
Modified: trunk/Source/WebCore/platform/network/HTTPParsers.cpp (202909 => 202910)
--- trunk/Source/WebCore/platform/network/HTTPParsers.cpp 2016-07-07 16:03:18 UTC (rev 202909)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.cpp 2016-07-07 16:24:14 UTC (rev 202910)
@@ -102,6 +102,17 @@
return pos != start;
}
+// See RFC 7230, Section 3.1.2.
+bool isValidReasonPhrase(const String& value)
+{
+ for (unsigned i = 0; i < value.length(); ++i) {
+ UChar c = value[i];
+ if (c == 0x7F || c > 0xFF || (c < 0x20 && c != '\t'))
+ return false;
+ }
+ return true;
+}
+
// See RFC 7230, Section 3.2.3.
bool isValidHTTPHeaderValue(const String& value)
{
Modified: trunk/Source/WebCore/platform/network/HTTPParsers.h (202909 => 202910)
--- trunk/Source/WebCore/platform/network/HTTPParsers.h 2016-07-07 16:03:18 UTC (rev 202909)
+++ trunk/Source/WebCore/platform/network/HTTPParsers.h 2016-07-07 16:24:14 UTC (rev 202910)
@@ -69,13 +69,14 @@
};
ContentDispositionType contentDispositionType(const String&);
+bool isValidReasonPhrase(const String&);
bool isValidHTTPHeaderValue(const String&);
bool isValidHTTPToken(const String&);
bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url);
Optional<std::chrono::system_clock::time_point> parseHTTPDate(const String&);
-String filenameFromHTTPContentDisposition(const String&);
+String filenameFromHTTPContentDisposition(const String&);
String extractMIMETypeFromMediaType(const String&);
-String extractCharsetFromMediaType(const String&);
+String extractCharsetFromMediaType(const String&);
void findCharsetInMediaType(const String& mediaType, unsigned int& charsetPos, unsigned int& charsetLen, unsigned int start = 0);
XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& failureReason, unsigned& failurePosition, String& reportURL);
AtomicString extractReasonPhraseFromHTTPStatusLine(const String&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes