xml-js icon indicating copy to clipboard operation
xml-js copied to clipboard

Special characters in XML attributes not being escaped correctly

Open eug48 opened this issue 6 years ago • 5 comments

Thanks very much for this very useful library. I've run into an issue since ampersands in XML attributes aren't being escaped by js2xml. This seems to have happened after the change described here: https://github.com/nashwaan/xml-js/issues/26#issuecomment-323543868 however the StackOverflow answer that is referenced seems to be incorrect or just very badly structured? The spec extract that is quoted seems to contradict its recommendation and attributes with ampersands don't validate properly - e.g. try https://validator.w3.org/check with

<?xml version="1.0"?>
<elt attr="abc&def"></elt>

eug48 avatar Jun 25 '18 14:06 eug48

@eug48 , you are right. I got it wrong when I based my solution on that StackOverflow thread. I wasn't aware about https://validator.w3.org/#validate_by_input+with_options online checking.

Now I can conclude correctly that the 5 characters: & < > " ' should be replaced with &amp; &lt; &gt; &quot; &#39; in both text of tags AND attributes.

Will need to find time to fix this issue.

nashwaan avatar Jul 03 '18 07:07 nashwaan

I also ran into this issue.

Dico200 avatar Feb 05 '20 23:02 Dico200

@nashwaan When this issue will resolve?

Shubu15 avatar Jun 30 '21 10:06 Shubu15

is there any update on this issue? thanks!

rdiazroman avatar Mar 08 '22 13:03 rdiazroman

Also experiencing this issue, raised here:

https://github.com/dolanmiu/docx/issues/2443

dolanmiu avatar Dec 31 '23 22:12 dolanmiu