Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for parsing quoted attributes with newlines.

Quoted attributes are allowed to contain newlines.
  • Loading branch information...
commit 6dc863fb2a371f8e647f787c0e40626c171a4351 1 parent 203499a
@mmzeeman authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/mochiweb_html.erl
View
10 src/mochiweb_html.erl
@@ -502,8 +502,6 @@ tokenize_quoted_attr_value(B, S=#decoder{offset=O}, Acc, Q) ->
tokenize_quoted_attr_value(B, S1, [Data|Acc], Q);
<<_:O/binary, Q, _/binary>> ->
{ iolist_to_binary(lists:reverse(Acc)), ?INC_COL(S) };
- <<_:O/binary, $\n, _/binary>> ->
- { iolist_to_binary(lists:reverse(Acc)), ?INC_LINE(S) };
<<_:O/binary, C, _/binary>> ->
tokenize_quoted_attr_value(B, ?INC_COL(S), [C|Acc], Q)
end.
@@ -1234,6 +1232,14 @@ parse_quoted_attr_test() ->
{ <<"img">>, [ { <<"src">>, <<"/images/icon>.png">> } ], [] }
]},
mochiweb_html:parse(D2)),
+
+ %% Quoted attributes can contain whitespace and newlines
+ D3 = <<"<html><a href=\"#\" onclick=\"javascript: test(1,\ntrue);\"></html>">>,
+ ?assertEqual(
+ {<<"html">>,[],[
+ { <<"a">>, [ { <<"href">>, <<"#">> }, {<<"onclick">>, <<"javascript: test(1,\ntrue);">>} ], [] }
+ ]},
+ mochiweb_html:parse(D3)),
ok.
parse_missing_attr_name_test() ->
Please sign in to comment.
Something went wrong with that request. Please try again.