altsvc: accept quoted ma and persist values

As mandated by the spec. Test 1654 is extended to verify.

Closes #4443
This commit is contained in:
Daniel Stenberg 2019-09-30 10:29:46 +02:00
parent 666a22675d
commit c24cf6c64c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 23 additions and 3 deletions

View file

@ -442,6 +442,7 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
char option[32];
unsigned long num;
char *end_ptr;
bool quoted = FALSE;
semip++; /* pass the semicolon */
result = getalnum(&semip, option, sizeof(option));
if(result)
@ -451,12 +452,21 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
if(*semip != '=')
continue;
semip++;
while(*semip && ISBLANK(*semip))
semip++;
if(*semip == '\"') {
/* quoted value */
semip++;
quoted = TRUE;
}
num = strtoul(semip, &end_ptr, 10);
if(num < ULONG_MAX) {
if((end_ptr != semip) && num && (num < ULONG_MAX)) {
if(strcasecompare("ma", option))
maxage = num;
else if(strcasecompare("persist", option) && (num == 1))
persist = TRUE;
if(quoted && (*end_ptr == '\"'))
end_ptr++;
}
semip = end_ptr;
}