diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-05-25 08:31:08 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-05-25 23:05:27 +0200 |
commit | d844f2b9ff50cfa7bf7f5b445d9f7eed7e6c3015 (patch) | |
tree | a5f27cbc6044fbda72db97a033d0e53a340b4c18 /lib | |
parent | 308c243db5b7425b454a981d4c0eb7bfac374b8b (diff) |
altsvc: fix parser for lines ending with CRLF
Fixed the alt-svc parser to treat a newline as end of line.
The unit tests in test 1654 were done without CRLF and thus didn't quite
match the real world. Now they use CRLF as well.
Reported-by: Peter Wu
Assisted-by: Peter Wu
Assisted-by: Jay Satiro
Fixes #5445
Closes #5446
Diffstat (limited to 'lib')
-rw-r--r-- | lib/altsvc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/altsvc.c b/lib/altsvc.c index f6c5c0612..bb72a33a4 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -431,6 +431,8 @@ static time_t debugtime(void *unused) #define time(x) debugtime(x) #endif +#define ISNEWLINE(x) (((x) == '\n') || (x) == '\r') + /* * Curl_altsvc_parse() takes an incoming alt-svc response header and stores * the data correctly in the cache. @@ -520,12 +522,12 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data, /* Handle the optional 'ma' and 'persist' flags. Unknown flags are skipped. */ for(;;) { - while(*p && ISBLANK(*p) && *p != ';' && *p != ',') + while(ISBLANK(*p)) p++; - if(!*p || *p == ',') + if(*p != ';') break; p++; /* pass the semicolon */ - if(!*p) + if(!*p || ISNEWLINE(*p)) break; result = getalnum(&p, option, sizeof(option)); if(result) { |