Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Unified Diff: sdk/lib/io/http_headers.dart

Issue 151123003: Skip bad cookies in http headers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_headers.dart
diff --git a/sdk/lib/io/http_headers.dart b/sdk/lib/io/http_headers.dart
index 1d7e9b55382bf03d76358e873cfd403a72bb9ffa..0be5c080d6d68dfb09c2e29e4a6b2845a32b4065 100644
--- a/sdk/lib/io/http_headers.dart
+++ b/sdk/lib/io/http_headers.dart
@@ -444,7 +444,7 @@ class _HttpHeaders implements HttpHeaders {
void parseCookieString(String s) {
int index = 0;
- bool done() => index == s.length;
+ bool done() => index == -1 || index == s.length;
void skipWS() {
while (!done()) {
@@ -471,14 +471,11 @@ class _HttpHeaders implements HttpHeaders {
return s.substring(start, index);
}
- void expect(String expected) {
- if (done()) {
- throw new HttpException("Failed to parse header value [$s]");
- }
- if (s[index] != expected) {
- throw new HttpException("Failed to parse header value [$s]");
- }
+ bool expect(String expected) {
+ if (done()) return false;
+ if (s[index] != expected) return false;
index++;
+ return true;
}
while (!done()) {
@@ -486,13 +483,19 @@ class _HttpHeaders implements HttpHeaders {
if (done()) return;
String name = parseName();
skipWS();
- expect("=");
+ if (!expect("=")) {
+ index = s.indexOf(';', index);
+ continue;
+ }
skipWS();
String value = parseValue();
cookies.add(new _Cookie(name, value));
skipWS();
if (done()) return;
- expect(";");
+ if (!expect(";")) {
+ index = s.indexOf(';', index);
+ continue;
+ }
}
}
List<String> values = _headers[HttpHeaders.COOKIE];
« no previous file with comments | « no previous file | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698