You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Negative range positions in malformed HTML fragment #2175
Hello, please see below a test program that tries to extract the text node range positions from the malformed fragment foo<p/>far. Notice the malformed tag <p/>.
import org.jsoup.nodes.*;
import org.jsoup.parser.*;
import org.jsoup.select.*;
public class Test {
public static void main(String[] args) {
HtmlTreeBuilder treeBuilder = new HtmlTreeBuilder();
Parser parser = new Parser(treeBuilder);
parser.setTrackPosition(true);
Document document = parser.parseInput("foo<p/>bar", "");
NodeTraversor.traverse((Node node, int depth) -> {
if (node instanceof TextNode textNode) {
Range sourceRange = textNode.sourceRange();
System.out.printf("text=%s start=%d end=%d%n",
textNode.text(),
sourceRange.start().pos(),
sourceRange.end().pos());
}
}, document);
}
}
Activity
jhy commentedon Jul 29, 2024
Thanks for the clear report, fixed!
Simplify character start position tracking
chore(deps): update all non-major dependencies (mulk/mulkcms2!58)