Closed jahson closed 3 years ago
Regular expression for header name was wrong, that caused headers like "P3P" to fail, because 3 was not in the set of accepted chars.
3
According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 the field name is defined as field name = token, the token is defined as token = 1*tchar, where tchar is
field name = token
token = 1*tchar
tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /"^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
ALPHA is defined in https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1 as
ALPHA
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
and DIGIT is defined as
DIGIT
DIGIT = %x30-39 ; 0-9
isName regular expression was /^[!#$%&'*+\-.09A-Z^_`a-z|~]+$/ and with all above info the issue is easily spotted, because 0, and 9 should have - between them, and the regular expression should look like /^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/.
isName
/^[!#$%&'*+\-.09A-Z^_`a-z|~]+$/
0
9
-
/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/
Ooof, good catch. Looks like just a typo.
Regular expression for header name was wrong, that caused headers like "P3P" to fail, because
3
was not in the set of accepted chars.According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 the field name is defined as
field name = token
, the token is defined astoken = 1*tchar
, where tchar isALPHA
is defined in https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1 asand
DIGIT
is defined asisName
regular expression was/^[!#$%&'*+\-.09A-Z^_`a-z|~]+$/
and with all above info the issue is easily spotted, because0
, and9
should have-
between them, and the regular expression should look like/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/
.