You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2017/08/14 15:38:18 UTC
[08/31] mochiweb commit: updated refs/heads/upstream to 23dc119
mochiweb_html tags must start with a letter (#171)
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/dd26e09c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/dd26e09c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/dd26e09c
Branch: refs/heads/upstream
Commit: dd26e09c9e30f1fa9f0bc6e7a78d552a6d404675
Parents: a1ed381
Author: vvoznesensky <vv...@gmail.com>
Authored: Tue Apr 12 06:09:07 2016 +0400
Committer: Bob Ippolito <bo...@redivi.com>
Committed: Mon Apr 11 19:09:07 2016 -0700
----------------------------------------------------------------------
src/mochiweb_html.erl | 4 +++-
test/mochiweb_html_tests.erl | 7 +++++++
2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/dd26e09c/src/mochiweb_html.erl
----------------------------------------------------------------------
diff --git a/src/mochiweb_html.erl b/src/mochiweb_html.erl
index 70723af..418f24c 100644
--- a/src/mochiweb_html.erl
+++ b/src/mochiweb_html.erl
@@ -54,6 +54,8 @@
-define(IS_WHITESPACE(C),
(C =:= $\s orelse C =:= $\t orelse C =:= $\r orelse C =:= $\n)).
+-define(IS_LETTER(C),
+ ((C >= $A andalso C =< $Z) orelse (C >= $a andalso C =< $z))).
-define(IS_LITERAL_SAFE(C),
((C >= $A andalso C =< $Z) orelse (C >= $a andalso C =< $z)
orelse (C >= $0 andalso C =< $9))).
@@ -349,7 +351,7 @@ tokenize(B, S=#decoder{offset=O}) ->
{S2, _} = find_gt(B, S1),
{{end_tag, Tag}, S2};
<<_:O/binary, "<", C, _/binary>>
- when ?IS_WHITESPACE(C); not ?IS_LITERAL_SAFE(C) ->
+ when ?IS_WHITESPACE(C); not ?IS_LETTER(C) ->
%% This isn't really strict HTML
{{data, Data, _Whitespace}, S1} = tokenize_data(B, ?INC_COL(S)),
{{data, <<$<, Data/binary>>, false}, S1};
http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/dd26e09c/test/mochiweb_html_tests.erl
----------------------------------------------------------------------
diff --git a/test/mochiweb_html_tests.erl b/test/mochiweb_html_tests.erl
index 0310b28..03bab5b 100644
--- a/test/mochiweb_html_tests.erl
+++ b/test/mochiweb_html_tests.erl
@@ -601,3 +601,10 @@ implicit_html_test() ->
[{<<"head">>, [], []},
{<<"body">>, [], []}]},
mochiweb_html:parse("<!doctype html><head></head><body></body>")).
+
+no_letter_no_tag_test() ->
+ ?assertEqual(
+ {<<"html">>,[],
+ [{<<"body">>,[],[<<"<3><!><*><<>>">>,{<<"body">>,[],[]}]}]},
+ mochiweb_html:parse(<<"<html><body><3><!><*><<>><body></html>">>)
+ ).