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

`Attributes.getValue(String qName)` sometimes returns values from previous elements

Open nedtwigg opened this issue 2 years ago • 4 comments

I have an entity with no attributes. But getValue("SomeKey") is returning a value from a previous element.

I think the problem is that these lines

https://github.com/FasterXML/aalto-xml/blob/0820590fcf56ec3d5ca14608d6145e14e56f2650/src/main/java/com/fasterxml/aalto/sax/SAXParserImpl.java#L654-L666

Are missing the || index >= _attrCount that this has

https://github.com/FasterXML/aalto-xml/blob/0820590fcf56ec3d5ca14608d6145e14e56f2650/src/main/java/com/fasterxml/aalto/sax/SAXParserImpl.java#L647-L652

nedtwigg avatar Dec 22 '22 00:12 nedtwigg

@nedtwigg Apologies for somehow missing this report. I don't know if it'd be possible, but I'd really like a reproduction (I assume "entity" in report means "element") to fix the problem.

I can try to build something on my end based on description and see how that goes; but may need help.

cowtowncoder avatar Jun 07 '24 02:06 cowtowncoder

Ok, no. I do need a test case here to reproduce the problem. And I think the issue is with lookup, not bounds checks; some state is not being cleared, likely.

cowtowncoder avatar Jun 07 '24 18:06 cowtowncoder

The thing I was using this for is still alive, but not currently under active development. I did a quick git log to look at the context from 2 years ago, and I can see the workaround in our codebase, but I can't quickly identify a reproducer testcase. I expect this project will become active again sometime in the next few months. When that happens, I'll provide the data here.

nedtwigg avatar Jun 10 '24 18:06 nedtwigg

@nedtwigg understood. Thank you for all help you can give.

cowtowncoder avatar Jun 10 '24 21:06 cowtowncoder