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

Unified Diff: net/spdy/spdy_alt_svc_wire_format.cc

Issue 2497223003: Allow IP literals in Alt-Svc hostnames. (Closed)
Patch Set: Created 4 years, 1 month 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 | net/spdy/spdy_alt_svc_wire_format_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_alt_svc_wire_format.cc
diff --git a/net/spdy/spdy_alt_svc_wire_format.cc b/net/spdy/spdy_alt_svc_wire_format.cc
index 38c8fdde36b044c3b1f37f95d05172a9e0d6a034..e94b4fa719569e1bebd5d8a29fe21a2b2849fbd6 100644
--- a/net/spdy/spdy_alt_svc_wire_format.cc
+++ b/net/spdy/spdy_alt_svc_wire_format.cc
@@ -303,20 +303,39 @@ bool SpdyAltSvcWireFormat::ParseAltAuthority(StringPiece::const_iterator c,
std::string* host,
uint16_t* port) {
host->clear();
- for (; c != end && *c != ':'; ++c) {
- if (*c == '"') {
- // Port is mandatory.
+ if (c == end) {
+ return false;
+ }
+ if (*c == '[') {
+ for (; c != end && *c != ']'; ++c) {
+ if (*c == '"') {
+ // Port is mandatory.
+ return false;
+ }
+ host->push_back(*c);
+ }
+ if (c == end) {
return false;
}
- if (*c == '\\') {
- ++c;
- if (c == end) {
+ DCHECK_EQ(']', *c);
+ host->push_back(*c);
+ ++c;
+ } else {
+ for (; c != end && *c != ':'; ++c) {
+ if (*c == '"') {
+ // Port is mandatory.
return false;
}
+ if (*c == '\\') {
+ ++c;
+ if (c == end) {
+ return false;
+ }
+ }
+ host->push_back(*c);
}
- host->push_back(*c);
}
- if (c == end) {
+ if (c == end || *c != ':') {
return false;
}
DCHECK_EQ(':', *c);
« no previous file with comments | « no previous file | net/spdy/spdy_alt_svc_wire_format_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698