Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support disabling General Entity Reference replacement in attribute values #65

Closed
otcdlink-simpleuser opened this issue Aug 29, 2018 · 6 comments
Milestone

Comments

@otcdlink-simpleuser
Copy link

With aalto-xml 1.1.0 disabling Entity Reference replacement causes an exception to be thrown in case of a non-standard Entity.

Using the test case of #64 with this line:

xmlInputFactory.setProperty( XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false ) ;

We get the following exception:

com.fasterxml.aalto.WFCException: General entity reference (&en;) encountered in entity expanding mode: operation not (yet) implemented
 at [row,col {unknown-source}]: [1,18]

	at com.fasterxml.aalto.in.XmlScanner.reportInputProblem(XmlScanner.java:1333)
	at com.fasterxml.aalto.in.ReaderScanner.handleEntityInText(ReaderScanner.java:1256)
	at com.fasterxml.aalto.in.ReaderScanner.collectValue(ReaderScanner.java:899)
	at com.fasterxml.aalto.in.ReaderScanner.handleStartElement(ReaderScanner.java:794)
	at com.fasterxml.aalto.in.ReaderScanner.nextFromProlog(ReaderScanner.java:236)
	at com.fasterxml.aalto.stax.StreamReaderImpl.next(StreamReaderImpl.java:790)
	at com.otcdlink.chiron.wire.StaxPlayground.entityReplacement2(StaxPlayground.java:80)
@cowtowncoder
Copy link
Member

XML specification requires DTD support to be handle general entity references, so as is Aalto can not really do this in standards-compliant way: it does not decode DTDs (although it may skip them relatively reliably), and thus can not detect invalid usage, and to skip ones that are declared (and error on undeclared).

But I guess it would be reasonable to allow quiet skipping by returning ENTITY_REFERENCE, if setting you mention is on.

@cowtowncoder cowtowncoder added the active Issue being actively worked on label Sep 18, 2018
@cjmamo
Copy link
Contributor

cjmamo commented Mar 16, 2021

Any news on this?

@cowtowncoder cowtowncoder removed the active Issue being actively worked on label Mar 16, 2021
@cowtowncoder
Copy link
Member

If there are news, there will update to the issue.

At this point I think a PR would be one way forward: I simply do not have time to add new features here.

cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 16, 2021
…tFactory.IS_REPLACING_ENTITY_REFERENCES is set to false

allow SAXParserFactoryImpl to be customised

Refs: FasterXML#65
@cjmamo
Copy link
Contributor

cjmamo commented Mar 16, 2021

PR opened: #74

cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 16, 2021
…putFactory.IS_REPLACING_ENTITY_REFERENCES is set to false

allow SAXParserFactoryImpl to be customised

Refs: FasterXML#65
@cowtowncoder
Copy link
Member

@claudemamo thank you for suggesting a fix! Unfortunately there are couple of issues with it; I'll add notes on PR itself.

cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
…ameter meant for retaining entities instead of misusing the StAX XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES feature

Refs: FasterXML#65
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
…ameter meant for retaining entities instead of misusing the StAX XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES feature

Refs: FasterXML#65
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
…ameter meant for retaining entities instead of misusing the StAX XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES feature

Refs: FasterXML#65
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
…ameter meant for retaining entities instead of misusing the StAX XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES feature

Refs: FasterXML#65
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Mar 18, 2021
…AL_ENTITIES to avoid confusion with existing EXPAND_ENTITIES parameter

Refs: FasterXML#65
cjmamo added a commit to cjmamo/aalto-xml that referenced this issue Apr 5, 2021
…IBUTE_GENERAL_ENTITIES

solve possible NullPointerException when referencing P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES property

Refs: FasterXML#65
cowtowncoder pushed a commit that referenced this issue Apr 26, 2021
…pu… (#74)

Implement #65: Add AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES which allows skipping handling of general entity references in attributes.
@cowtowncoder cowtowncoder changed the title Support disabling Entity Reference replacement Support disabling General Entity Reference replacement in attribute values Apr 26, 2021
@cowtowncoder cowtowncoder added this to the 1.3.0 milestone Apr 26, 2021
cowtowncoder added a commit that referenced this issue Apr 26, 2021
@cowtowncoder
Copy link
Member

Merged, with just one significant change: AaltoInputProperties.P_RETAIN_ATTRIBUTE_GENERAL_ENTITIES is both the Stax AND SAX Feature name to use, instead of trying to reuse existing SAX feature (http://xml.org/sax/features/external-general-entities) -- latter has its own semantics and should not be reused in my opinion.

Also added a test so that new feature is usable with Stax API as well.

Will wait a bit before releasing 1.3.0, but planning to do that relatively soon.

cjmamo added a commit to smooks/smooks that referenced this issue Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants