elharo opened a new pull request, #136: URL: https://github.com/apache/xerces-j/pull/136
## Summary `DOMUtil.copyInto` throws a `NullPointerException` when the source node is a childless node that has a following sibling. This is the bug described in [XERCESJ-1289](https://issues.apache.org/jira/browse/XERCESJ-1289). For example, copying node `b` from: ```xml <a> <b/> <c><d/></c> </a> ``` walks past `b` into its sibling `c`, then keeps climbing the source tree until `dest` becomes `null`, causing an NPE. Even when no NPE occurs, the implementation incorrectly copies siblings of the source node instead of only the source subtree. ## Fix When the source node itself has no children, stop after copying it instead of advancing to its next sibling. This is done by guarding the advance branch with `place != start`. ## Tests Added `tests/org/apache/xerces/util/DOMUtilTest.java` with two regression tests: * `testCopyFirstChildWithoutChildren` - reproduces the NPE and verifies only the source node is copied. * `testCopyLeadingTextDoesNotCopySiblings` - verifies a leading text node does not cause its following siblings to be copied. Both tests fail before the fix (including the NPE) and pass after it. The full `ant test` suite passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
