From ca34a6c16a146cb5780a9c28cb5614e2e846d318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Z=C3=B6ger?= Date: Wed, 8 Mar 2017 14:11:53 +0100 Subject: [PATCH 1/2] Removes redundant function clause --- lib/xmerl/src/xmerl_scan.erl | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/xmerl/src/xmerl_scan.erl b/lib/xmerl/src/xmerl_scan.erl index 95dc82e5c954..4eacb9fc4d46 100644 --- a/lib/xmerl/src/xmerl_scan.erl +++ b/lib/xmerl/src/xmerl_scan.erl @@ -474,8 +474,6 @@ event(_X, S) -> %% into multiple objects (in which case {Acc',Pos',S'} should be returned.) %% If {Acc',S'} is returned, Pos will be incremented by 1 by default. %% Below is an example of an acceptable operation -acc(X = #xmlText{value = Text}, Acc, S) -> - {[X#xmlText{value = Text}|Acc], S}; acc(X, Acc, S) -> {[X|Acc], S}. From 027c94a04a3c78daa351b025c68694f01c566560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Z=C3=B6ger?= Date: Wed, 8 Mar 2017 14:56:06 +0100 Subject: [PATCH 2/2] Improves accumulator fun in xmerl_scan so that only one #xmlText record is returned for strings which have character references * Adds test with character reference in numeric form * Updates test for ticket_7430 --- lib/xmerl/src/xmerl_scan.erl | 2 ++ lib/xmerl/test/xmerl_SUITE.erl | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/xmerl/src/xmerl_scan.erl b/lib/xmerl/src/xmerl_scan.erl index 4eacb9fc4d46..18fe7031b990 100644 --- a/lib/xmerl/src/xmerl_scan.erl +++ b/lib/xmerl/src/xmerl_scan.erl @@ -474,6 +474,8 @@ event(_X, S) -> %% into multiple objects (in which case {Acc',Pos',S'} should be returned.) %% If {Acc',S'} is returned, Pos will be incremented by 1 by default. %% Below is an example of an acceptable operation +acc(#xmlText{value = Text}, [X = #xmlText{value = AccText}], S) -> + {[X#xmlText{value = AccText ++ Text}], S}; acc(X, Acc, S) -> {[X|Acc], S}. diff --git a/lib/xmerl/test/xmerl_SUITE.erl b/lib/xmerl/test/xmerl_SUITE.erl index 58c462483c7d..2e383f95c5bb 100644 --- a/lib/xmerl/test/xmerl_SUITE.erl +++ b/lib/xmerl/test/xmerl_SUITE.erl @@ -55,7 +55,7 @@ groups() -> {misc, [], [latin1_alias, syntax_bug1, syntax_bug2, syntax_bug3, pe_ref1, copyright, testXSEIF, export_simple1, export, - default_attrs_bug, xml_ns]}, + default_attrs_bug, xml_ns, scan_splits_string_bug]}, {eventp_tests, [], [sax_parse_and_export]}, {ticket_tests, [], [ticket_5998, ticket_7211, ticket_7214, ticket_7430, @@ -268,6 +268,10 @@ xml_ns(Config) -> } = xmerl_scan:string(Doc2, [{namespace_conformant, true}]), ok. +scan_splits_string_bug(_Config) -> + {#xmlElement{ content = [#xmlText{ value = "Jimmy Zöger" }] }, []} + = xmerl_scan:string("Jimmy Zöger"). + pe_ref1(Config) -> file:set_cwd(datadir(Config)), {#xmlElement{},[]} = xmerl_scan:file(datadir_join(Config,[misc,"PE_ref1.xml"]),[{validation,true}]). @@ -533,8 +537,7 @@ ticket_7430(Config) -> {xmlElement,a,a,[], {xmlNamespace,[],[]}, [],1,[], - [{xmlText,[{a,1}],1,[],"é",text}, - {xmlText,[{a,1}],2,[],"\né",text}], + [{xmlText,[{a,1}],1,[],"é\né",text}], [],_,undeclared} -> ok; _ ->