This commit is contained in:
matt@emericklaw.co.uk 2018-09-06 14:38:26 +01:00
parent 84adff578f
commit 664760c99c
4 changed files with 42 additions and 1 deletions

View File

@ -20,7 +20,7 @@ export class V2XmlFormatter implements XmlFormatter {
xml = xml.replace(/"\s+(?=[^\s]+=)/g, "\" "); // spaces between attributes
xml = xml.replace(/"\s+(?=>)/g, "\""); // spaces between the last attribute and tag close (>)
xml = xml.replace(/"\s+(?=\/>)/g, "\" "); // spaces between the last attribute and tag close (/>)
xml = xml.replace(/[^ <>="]\s+[^ <>="]+=/g, (match: string) => { // spaces between the node name and the first attribute
xml = xml.replace(/(?!<!\[CDATA\[)[^ <>="]\s+[^ <>="]+=(?![^<]*?\]\]>)/g, (match: string) => { // spaces between the node name and the first attribute
return match.replace(/\s+/g, " ");
});

View File

@ -92,6 +92,9 @@ describe("V2XmlFormatter", () => {
testFormatter(xmlFormatter, options, "issue-200");
});
it("should not remove spaces between the node name and the first attribute within CDATA", () => {
testFormatter(xmlFormatter, options, "issue-227");
});
});
});

View File

@ -0,0 +1,19 @@
<Job>
<SQLQuery test="">
<SQLSelect Test="test" test="test">
<![CDATA[
select
*
from test
where
aaa.aaa='AAA' and
isnull(BBB.BBB,0)=0 and
isnull(CCTestC.CCC,0)=1 and
DDD.DDD is null and
exists (select 1 from EEE where EEE.EEE=EEE.EEE and EEE is null) and
exists (select 1 from FFF where FFF.FFF=FFF.FFF) and
'{GGG}' like '%'+GGG.GGG+'%'
]]>
</SQLSelect>
</SQLQuery>
</Job>

View File

@ -0,0 +1,19 @@
<Job>
<SQLQuery test="">
<SQLSelect Test="test" test="test">
<![CDATA[
select
*
from test
where
aaa.aaa='AAA' and
isnull(BBB.BBB,0)=0 and
isnull(CCTestC.CCC,0)=1 and
DDD.DDD is null and
exists (select 1 from EEE where EEE.EEE=EEE.EEE and EEE is null) and
exists (select 1 from FFF where FFF.FFF=FFF.FFF) and
'{GGG}' like '%'+GGG.GGG+'%'
]]>
</SQLSelect>
</SQLQuery>
</Job>