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

Unified Diff: runtime/bin/http_parser.dart

Issue 10033023: Fix bug in HTTP header parsing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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/src/io/HttpParserTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/http_parser.dart
diff --git a/runtime/bin/http_parser.dart b/runtime/bin/http_parser.dart
index 2e8d8fa26e15943b79c9e9690044da21461b3fed..f3ea7c52dc72dcabee7aff12529e3064adaa62ec 100644
--- a/runtime/bin/http_parser.dart
+++ b/runtime/bin/http_parser.dart
@@ -259,12 +259,17 @@ class _HttpParser {
if (byte == _CharCode.COLON) {
_state = _State.HEADER_VALUE_START;
} else {
+ if (!_isTokenChar(byte)) {
+ throw new HttpParserException("Invalid header field name");
+ }
_headerField.addCharCode(_toLowerCase(byte));
}
break;
case _State.HEADER_VALUE_START:
- if (byte != _CharCode.SP && byte != _CharCode.HT) {
+ if (byte == _CharCode.CR) {
+ _state = _State.HEADER_VALUE_FOLDING_OR_ENDING;
+ } else if (byte != _CharCode.SP && byte != _CharCode.HT) {
// Start of new header value.
_headerValue.addCharCode(byte);
_state = _State.HEADER_VALUE;
@@ -518,6 +523,10 @@ class _HttpParser {
_remainingContent = null;
}
+ bool _isTokenChar(int byte) {
+ return byte > 31 && byte < 128 && _Const.SEPARATORS.indexOf(byte) == -1;
+ }
+
int _toLowerCase(int byte) {
final int aCode = "A".charCodeAt(0);
final int zCode = "Z".charCodeAt(0);
« no previous file with comments | « no previous file | tests/standalone/src/io/HttpParserTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698