From commits-return-32159-archive-asf-public=cust-asf.ponee.io@couchdb.apache.org Sun Feb 18 18:29:53 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 33B8D1807B4 for ; Sun, 18 Feb 2018 18:29:51 +0100 (CET) Received: (qmail 75501 invoked by uid 500); 18 Feb 2018 17:29:49 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 75237 invoked by uid 99); 18 Feb 2018 17:29:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Feb 2018 17:29:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7575DF3305; Sun, 18 Feb 2018 17:29:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wohali@apache.org To: commits@couchdb.apache.org Date: Sun, 18 Feb 2018 17:30:31 -0000 Message-Id: <57d575a4872e4e8eae69c57061002d33@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [46/50] mochiweb commit: updated refs/heads/master to 999f464 Handle missing closing tag for all empty elements (#190) I got the full list of elements from: https://developer.mozilla.org/en-US/docs/Glossary/empty_element Project: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/commit/0a052380 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/tree/0a052380 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/diff/0a052380 Branch: refs/heads/master Commit: 0a05238063668fec5a7ebb2037dd11552428fe8a Parents: a6fdb9a Author: Ben Olive Authored: Sat Aug 12 19:28:33 2017 -0400 Committer: Bob Ippolito Committed: Sat Aug 12 16:28:33 2017 -0700 ---------------------------------------------------------------------- src/mochiweb_html.erl | 13 +++++++---- test/mochiweb_html_tests.erl | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/0a052380/src/mochiweb_html.erl ---------------------------------------------------------------------- diff --git a/src/mochiweb_html.erl b/src/mochiweb_html.erl index df21a8f..95a2b44 100644 --- a/src/mochiweb_html.erl +++ b/src/mochiweb_html.erl @@ -463,16 +463,21 @@ destack([{Tag, Attrs, Acc}]) -> destack([{T1, A1, Acc1}, {T0, A0, Acc0} | Rest]) -> destack([{T0, A0, [{T1, A1, lists:reverse(Acc1)} | Acc0]} | Rest]). +is_singleton(<<"area">>) -> true; +is_singleton(<<"base">>) -> true; is_singleton(<<"br">>) -> true; +is_singleton(<<"col">>) -> true; +is_singleton(<<"embed">>) -> true; is_singleton(<<"hr">>) -> true; is_singleton(<<"img">>) -> true; is_singleton(<<"input">>) -> true; -is_singleton(<<"base">>) -> true; -is_singleton(<<"meta">>) -> true; +is_singleton(<<"keygen">>) -> true; is_singleton(<<"link">>) -> true; -is_singleton(<<"area">>) -> true; +is_singleton(<<"meta">>) -> true; is_singleton(<<"param">>) -> true; -is_singleton(<<"col">>) -> true; +is_singleton(<<"source">>) -> true; +is_singleton(<<"track">>) -> true; +is_singleton(<<"wbr">>) -> true; is_singleton(_) -> false. tokenize_data(B, S=#decoder{offset=O}) -> http://git-wip-us.apache.org/repos/asf/couchdb-mochiweb/blob/0a052380/test/mochiweb_html_tests.erl ---------------------------------------------------------------------- diff --git a/test/mochiweb_html_tests.erl b/test/mochiweb_html_tests.erl index 03bab5b..5dceb9a 100644 --- a/test/mochiweb_html_tests.erl +++ b/test/mochiweb_html_tests.erl @@ -428,6 +428,52 @@ dumb_br_test() -> {<<"div">>,[],[{<<"br">>, [], []}, {<<"br">>, [], []}, <<"z">>]}, mochiweb_html:parse("


z

")). +empty_elements_test() -> + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"area">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"base">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"br">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
a
z
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"col">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"embed">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"hr">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
a
z
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"img">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"input">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"keygen">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"link">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"meta">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"param">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"source">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"track">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")), + ?assertEqual( + {<<"div">>,[],[<<"a">>,{<<"wbr">>,[],[]},<<"z">>]}, + mochiweb_html:parse("
az
")). php_test() -> %% http://code.google.com/p/mochiweb/issues/detail?id=71