Skip to content
Browse files

Fix parsing of unescaped lt chars.

  • Loading branch information...
1 parent 5305a4b commit 203499a9e108bed8cf2cf6d8b8606128ed806361 @mmzeeman committed Apr 26, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/mochiweb_html.erl
View
16 src/mochiweb_html.erl
@@ -312,7 +312,8 @@ tokenize(B, S=#decoder{offset=O}) ->
{Tag, S1} = tokenize_literal(B, ?ADV_COL(S, 2)),
{S2, _} = find_gt(B, S1),
{{end_tag, Tag}, S2};
- <<_:O/binary, "<", C, _/binary>> when ?IS_WHITESPACE(C) ->
+ <<_:O/binary, "<", C, _/binary>>
+ when ?IS_WHITESPACE(C); not ?IS_LITERAL_SAFE(C) ->
%% This isn't really strict HTML
{{data, Data, _Whitespace}, S1} = tokenize_data(B, ?INC_COL(S)),
{{data, <<$<, Data/binary>>, false}, S1};
@@ -1280,4 +1281,17 @@ parse_amp_test_() ->
[{<<"body">>,[],[<<"&">>]}]},
mochiweb_html:parse("<html><body>&</body></html>"))].
+parse_unescaped_lt_test() ->
+ D1 = <<"<div> < < <a href=\"/\">Back</a></div>">>,
+ ?assertEqual(
+ {<<"div">>, [], [<<" < < ">>, {<<"a">>, [{<<"href">>, <<"/">>}],
+ [<<"Back">>]}]},
+ mochiweb_html:parse(D1)),
+
+ D2 = <<"<div> << <a href=\"/\">Back</a></div>">>,
+ ?assertEqual(
+ {<<"div">>, [], [<<" << ">>, {<<"a">>, [{<<"href">>, <<"/">>}],
+ [<<"Back">>]}]},
+ mochiweb_html:parse(D2)).
+
-endif.

0 comments on commit 203499a

Please sign in to comment.
Something went wrong with that request. Please try again.