Valid xpath crashes the lib with NPE
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 474
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
Example xml snippet:
<tbody> <tr> <td>NoLuck</td> <td> <span>NoHit</span> </td> </tr> <tr> <td>whatever</td> <td> <span>ShouldHit</span> </td> </tr> <tr> <td>Again</td> <td> <span>NoHit</span> </td> </tr> </tbody>
XPath:
//table/tbody/tr[contains(td,'whatever']/td/span/text()It should return: ShouldHit as verified with w3cSchool online tool.
Instead it throws NullPointerException:Exception in thread "main" java.lang.NullPointerException
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at us.codecraft.xsoup.xevaluator.StructuralEvaluator$ImmediateParent.matches(StructuralEvaluator.java:84)
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at us.codecraft.xsoup.xevaluator.StructuralEvaluator$ImmediateParent.matches(StructuralEvaluator.java:84)
at us.codecraft.xsoup.xevaluator.CombiningEvaluator$And.matches(CombiningEvaluator.java:53)
at org.jsoup.select.Collector$Accumulator.head(Collector.java:42)
at org.jsoup.select.NodeTraversor.traverse(NodeTraversor.java:31)
at org.jsoup.select.Collector.collect(Collector.java:24)
at us.codecraft.xsoup.xevaluator.DefaultXPathEvaluator.evaluate(DefaultXPathEvaluator.java:29)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied XML and XPath example, then start with CombiningEvaluator.java:53 and follow the stack through StructuralEvaluator.java:84 and DefaultXPathEvaluator.java:29. The work is done when the expression returns “ShouldHit” without throwing a NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100