oblac / jodd-lagarto

Java HTML parsers suite.
https://lagarto.jodd.org
BSD 2-Clause "Simplified" License
20 stars 5 forks source link

`:has` and `:contains` not interoperable #23

Open neroux opened 1 year ago

neroux commented 1 year ago

Hi @igr,

it seems these two pseudo selectors are not interoperable, as running the query a:has(span:contains("sometext")) against Jerry.find() throws the following exception.

Caught: jodd.csselly.CSSellyException: Illegal character <">. (state: 8)
jodd.csselly.CSSellyException: Illegal character <">. (state: 8)
        at jodd.csselly.CSSellyLexer.yylex(CSSellyLexer.java:887)
        at jodd.csselly.CSSelly.parse(CSSelly.java:59)
        at jodd.csselly.CSSelly.parse(CSSelly.java:94)
        at jodd.csselly.selector.PseudoFunctions$HAS.parseExpression(PseudoFunctions.java:205)
        at jodd.csselly.selector.PseudoFunctions$HAS.parseExpression(PseudoFunctions.java:198)
        at jodd.csselly.selector.PseudoFunctionSelector.<init>(PseudoFunctionSelector.java:101)
        at jodd.csselly.CssSelector.addPseudoFunctionSelector(CssSelector.java:154)
        at jodd.csselly.CSSellyLexer.yylex(CSSellyLexer.java:942)
        at jodd.csselly.CSSelly.parse(CSSelly.java:59)
        at jodd.csselly.CSSelly.parse(CSSelly.java:94)
        at jodd.lagarto.dom.NodeSelector.select(NodeSelector.java:54)
        at jodd.jerry.Jerry.find(Jerry.java:346)

a:contains("sometext") and a:has(span) on the other hand work fine.

Not a show stopper right now, but thought I should let you know.

igr commented 1 year ago

I will take a look as soon I return from a vacation! Thanx!

neroux commented 1 year ago

Nothing urgent, just an FYI

Enjoy the time off :)