Check for invalid colon in header value
This commit is contained in:
parent
2cec0d0c09
commit
2b2e4d756c
|
|
@ -109,6 +109,8 @@ parser( Rest, headers , State) -> goto(headers, hdrname,
|
|||
parser(<<?COLON, Rest/binary>>, hdrname , State) -> goto(hdrname, hdrvalue, Rest, State);
|
||||
parser(<<?LF, Rest/binary>>, hdrname , State) -> goto(hdrname, headers, Rest, State);
|
||||
parser(<<?LF, Rest/binary>>, hdrvalue, State) -> goto(hdrvalue, headers, Rest, State);
|
||||
%% trap invalid colons
|
||||
parser(<<?COLON, Rest/binary>>, hdrvalue, State) -> {error, {unexpected_char_in_header_value, [?COLON]}};
|
||||
%% accumulate
|
||||
parser(<<Ch:8, Rest/binary>>, Term , State) -> parser(Rest, Term, accum(Ch, State)).
|
||||
|
||||
|
|
@ -236,7 +238,7 @@ escape1(?COLON) -> [?BSL, ?COLON_ESC];
|
|||
escape1(?BSL) -> [?BSL, ?BSL_ESC];
|
||||
escape1(?LF) -> [?BSL, ?LF_ESC];
|
||||
escape1(?CR) -> [?BSL, ?CR_ESC];
|
||||
escape1(C) -> C.
|
||||
escape1(Ch) -> Ch.
|
||||
|
||||
firstnull(Content) -> firstnull(Content, 0).
|
||||
|
||||
|
|
|
|||
|
|
@ -163,6 +163,10 @@ header_value_with_cr_test() ->
|
|||
Content = "COMMAND\nheader:val\rue\n\n\0",
|
||||
{error, {unexpected_chars_in_header, "\ru"}} = parse(Content).
|
||||
|
||||
header_value_with_colon_test() ->
|
||||
Content = "COMMAND\nheader:val:ue\n\n\0",
|
||||
{error, {unexpected_char_in_header_value, ":"}} = parse(Content).
|
||||
|
||||
headers_escaping_roundtrip_test() ->
|
||||
Content = "COMMAND\nhead\\r\\c\\ner:\\c\\n\\r\\\\\n\n\0",
|
||||
{ok, Frame, _} = parse(Content),
|
||||
|
|
|
|||
Loading…
Reference in New Issue