Closed HeikoTheissen closed 1 year ago
This is a great thing to support, and I'm frankly amazed at how small the code change is.
I'm wondering if it's a patch or breaking change, if anyone is depending on the incorrect behavior, since this library is so old and has been mostly untouched for so long. Also, I have a few ideas of some cases that might surface some edge cases, but I wouldn't be surprised if just works as it is. I'll poke at it tonight, thanks!
To avoid a breaking change, the new behavior could be made conditional on a setting during sax instantiation:
sax.parser({unparsedEntities: true})
leads to the new behaviorsax.parser()
retains the current behaviorThanks for merging this and updating https://www.npmjs.com/package/sax !
Do you also plan to mention the new option unparsedEntities
on the README.md?
Hey hey! Sorry to pester, just noting that this implementation actually has a bug that renders the new option unusable in many cases. In SVGO, it's preventing us from migrating from our (unmaintained) fork of sax back to upstream.
I've already opened a pull request that explains and resolves the issue, includes tests, and I also checked by parsing the conformance tests for XML to ensure no exceptions occur. Before, with the option enabled, the conformance test suite threw an exception.
Would really appreciate it if others could take a peek when they have time.
I've also fixed a few other bugs impacting us in separate pull requests btw.
Issue 1
Entity declarations that involve XML elements, like in
wrongly contribute a text node, which leads to
whereas they should contribute XML elements and lead to
Without the patch to
lib/sax.js
, the new test casetest/entity-elem.js
fails withWith the patch, it passes.
Issue 2
Entity declarations that involve other entities, like in
are completely resolved, leading to
instead of
Without the patch to
lib/sax.js
, the new test casetest/entity-recursive.js
fails withWith the patch, it passes.