Bump org.jsoup:jsoup from 1.21.1 to 1.22.1 by dependabot[bot] · Pull Request #1367 · Together-Java/TJ-Bot
Bumps org.jsoup:jsoup from 1.21.1 to 1.22.1.
Release notes
Sourced from org.jsoup:jsoup's releases.
jsoup Java HTML Parser release 1.22.1
jsoup 1.22.1 is out now, adding support for the
re2jregular expression engine for regex-based CSS selectors, a configurable maximum parser depth, and numerous bug fixes and improvements.jsoup is a Java library for working with real-world HTML and XML. It provides a very convenient API for extracting and manipulating data, using the best of HTML5 DOM methods and CSS selectors.
Download jsoup now.
Improvements
- Added support for using the
re2jregular expression engine for regex-based CSS selectors (e.g.[attr~=regex],:matches(regex)), which ensures linear-time performance for regex evaluation. This allows safer handling of arbitrary user-supplied query regexes. To enable, add thecom.google.re2jdependency to your classpath, e.g.:<dependency> <groupId>com.google.re2j</groupId> <artifactId>re2j</artifactId> <version>1.8</version> </dependency>(If you already have that dependency in your classpath, but you want to keep using the Java regex engine, you can disable re2j via
System.setProperty("jsoup.useRe2j", "false").) You can confirm that the re2j engine has been enabled correctly by callingRegex.usingRe2j(). #2407
- Added an instance method
Parser#unescape(String, boolean)that unescapes HTML entities using the parser's configuration (e.g. to support error tracking), complementing the existing static utilityParser.unescapeEntities(String, boolean). #2396- Added a configurable maximum parser depth (to limit the number of open elements on stack) to both HTML and XML parsers. The HTML parser now defaults to a depth of 512 to match browser behavior, and protect against unbounded stack growth, while the XML parser keeps unlimited depth by default, but can opt into a limit via
Parser.setMaxDepth(). #2421- Build: added CI coverage for JDK 25 #2403
- Build: added a CI fuzzer for contextual fragment parsing (in addition to existing full body HTML and XML fuzzers). [oss-fuzz #14041](google/oss-fuzz#14041)
Changes
- Set a removal schedule of jsoup 1.24.1 for previously deprecated APIs.
Bug Fixes
- Previously cached child
Elementsof anElementwere not correctly invalidated inNode#replaceWith(Node), which could lead to incorrect results when subsequently callingElement#children(). #2391- Attribute selector values are now compared literally without trimming. Previously, jsoup trimmed whitespace from selector values and from element attribute values, which could cause mismatches with browser behavior (e.g.
[attr=" foo "]). Now matches align with the CSS specification and browser engines. #2380- When using the JDK HttpClient, any system default proxy (
ProxySelector.getDefault()) was ignored. Now, the system proxy is used if a per-request proxy is not set. #2388, #2390- A
ValidationExceptioncould be thrown in the adoption agency algorithm with particularly broken input. Now logged as a parse error. #2393- Null characters in the HTML body were not consistently removed; and in foreign content were not correctly replaced. #2395
- An
IndexOutOfBoundsExceptioncould be thrown when parsing a body fragment with crafted input. Now logged as a parse error. #2397, #2406- When using StructuralEvaluators (e.g., a
parent childselector) across many retained threads, their memoized results could also be retained, increasing memory use. These results are now cleared immediately after use, reducing overall memory consumption. #2411- Cloning a
Parsernow preserves any customTagSetapplied to the parser. #2422, #2423- Custom tags marked as
Tag.Voidnow parse and serialize like the built-in void elements: they no longer consume following content, and the XML serializer emits the expected self-closing form. #2425- The
<br>element is once again classified as an inline tag (Tag.isBlock() == false), matching common developer expectations and its role as phrasing content in HTML, while pretty-printing and text extraction continue to treat it as a line break in the rendered output. #2387, #2439- Fixed an intermittent truncation issue when fetching and parsing remote documents via
Jsoup.connect(url).get(). On responses without a charset header, the initial charset sniff could sometimes (depending on buffering /available()behavior) be mistaken for end-of-stream and a partial parse reused, dropping trailing content. #2448TagSetcopies no longer mutate their template during lazy lookups, preventing cross-threadConcurrentModificationExceptionwhen parsing with shared sessions. #2453- Fixed parsing of
<svg>foreignObjectcontent nested within a<p>, which could incorrectly move the HTML subtree outside the SVG. #2452Internal Changes
- Deprecated internal helper
org.jsoup.internal.Functions(for removal in v1.23.1). This was previously used to support older Android API levels without fulljava.util.functioncoverage; jsoup now requires core library desugaring so this indirection is no longer necessary. #2412
My sincere thanks to everyone who contributed to this release! If you have any suggestions for the next release, I would love to hear them; please get in touch via jsoup discussions, or with me directly.
You can also follow me (@jhy@tilde.zone) on Mastodon / Fediverse to receive occasional notes about jsoup releases.
... (truncated)
Changelog
Sourced from org.jsoup:jsoup's changelog.
1.22.1 (2026-Jan-01)
Improvements
- Added support for using the
re2jregular expression engine for regex-based CSS selectors (e.g.[attr~=regex],:matches(regex)), which ensures linear-time performance for regex evaluation. This allows safer handling of arbitrary user-supplied query regexes. To enable, add thecom.google.re2jdependency to your classpath, e.g.:<dependency> <groupId>com.google.re2j</groupId> <artifactId>re2j</artifactId> <version>1.8</version> </dependency>(If you already have that dependency in your classpath, but you want to keep using the Java regex engine, you can disable re2j via
System.setProperty("jsoup.useRe2j", "false").) You can confirm that the re2j engine has been enabled correctly by callingorg.jsoup.helper.Regex.usingRe2j(). #2407
- Added an instance method
Parser#unescape(String, boolean)that unescapes HTML entities using the parser's configuration (e.g. to support error tracking), complementing the existing static utilityParser.unescapeEntities(String, boolean). #2396- Added a configurable maximum parser depth (to limit the number of open elements on stack) to both HTML and XML parsers. The HTML parser now defaults to a depth of 512 to match browser behavior, and protect against unbounded stack growth, while the XML parser keeps unlimited depth by default, but can opt into a limit via
org.jsoup.parser.Parser#setMaxDepth. #2421- Build: added CI coverage for JDK 25 #2403
- Build: added a CI fuzzer for contextual fragment parsing (in addition to existing full body HTML and XML fuzzers). [oss-fuzz #14041](google/oss-fuzz#14041)
Changes
- Set a removal schedule of jsoup 1.24.1 for previously deprecated APIs.
Bug Fixes
- Previously cached child
Elementsof anElementwere not correctly invalidated inNode#replaceWith(Node), which could lead to incorrect results when subsequently callingElement#children(). #2391- Attribute selector values are now compared literally without trimming. Previously, jsoup trimmed whitespace from selector values and from element attribute values, which could cause mismatches with browser behavior (e.g.
[attr=" foo "]). Now matches align with the CSS specification and browser engines. #2380- When using the JDK HttpClient, any system default proxy (
ProxySelector.getDefault()) was ignored. Now, the system proxy is used if a per-request proxy is not set. #2388, #2390- A
ValidationExceptioncould be thrown in the adoption agency algorithm with particularly broken input. Now logged as a parse error. #2393- Null characters in the HTML body were not consistently removed; and in foreign content were not correctly replaced. #2395
- An
IndexOutOfBoundsExceptioncould be thrown when parsing a body fragment with crafted input. Now logged as a parse error. #2397, #2406- When using StructuralEvaluators (e.g., a
parent childselector) across many retained threads, their memoized results could also be retained, increasing memory use. These results are now cleared immediately after use, reducing overall memory consumption. #2411- Cloning a
Parsernow preserves any customTagSetapplied to the parser. #2422, #2423- Custom tags marked as
Tag.Voidnow parse and serialize like the built-in void elements: they no longer consume following content, and the XML serializer emits the expected self-closing form. #2425- The
<br>element is once again classified as an inline tag (Tag.isBlock() == false), matching common developer expectations and its role as phrasing content in HTML, while pretty-printing and text extraction continue to treat it as a line break in the rendered output. #2387, #2439- Fixed an intermittent truncation issue when fetching and parsing remote documents via
Jsoup.connect(url).get(). On responses without a charset header, the initial charset sniff could sometimes (depending on buffering /available()behavior) be mistaken for end-of-stream and a partial parse reused, dropping trailing content. #2448TagSetcopies no longer mutate their template during lazy lookups, preventing cross-threadConcurrentModificationExceptionwhen parsing with shared sessions. #2453- Fixed parsing of
<svg>foreignObjectcontent nested within a<p>, which could incorrectly move the HTML subtree outside the SVG. #2452Internal Changes
- Deprecated internal helper
org.jsoup.internal.Functions(for removal in v1.23.1). This was previously used to support older Android API levels without fulljava.util.functioncoverage; jsoup now requires core library desugaring so this indirection is no longer necessary. #24121.21.2 (2025-Aug-25)
Changes
- Deprecated internal (yet visible) methods
Normalizer#normalize(String, bool)andAttribute#shouldCollapseAttribute(Document.OutputSettings). These will be removed in a future version.- Deprecated
Connection#sslSocketFactory(SSLSocketFactory)in favor of the newConnection#sslContext(SSLContext). UsingsslSocketFactorywill force the use of the legacyHttpUrlConnectionimplementation, which does not support HTTP/2. #2370Improvements
- When pretty-printing, if there are consecutive text nodes (via DOM manipulation), the non-significant whitespace between them will be collapsed. #2349.
- Updated
Connection.Response#statusMessage()to return a simple loggable string message (e.g. "OK") when using theHttpClientimplementation, which doesn't otherwise return any server-set status message. #2356Attributes#size()andAttributes#isEmpty()now exclude any internal attributes (such as user data) from their count. This aligns with the attributes' serialized output and iterator. #2369- Added
Connection#sslContext(SSLContext)to provide a custom SSL (TLS) context to requests, supporting both theHttpClientand the legacyHttUrlConnectionimplementations. #2370
... (truncated)
Commits
8dd66fe[maven-release-plugin] prepare release jsoup-1.22.1d924385Changelog prep for v1.22.10f3100cBump actions/upload-artifact from 5 to 6 (#2457)cf6ac20Bump org.apache.maven.plugins:maven-release-plugin from 3.3.0 to 3.3.1 (#2455)6bef938Fix parsing of SVG foreignObject in paragraphs9b1c0fcBump org.apache.maven.plugins:maven-release-plugin from 3.2.0 to 3.3.0 (#2450)1415e64Bump actions/checkout from 5 to 6 (#2451)0e99fd9Isolate TagSet copies to prevent shared mutation (#2453)90019cbBump com.github.siom79.japicmp:japicmp-maven-plugin from 0.24.2 to 0.25.0 (#2...9395269Don't preemptively close- Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot mergewill merge this PR after your CI passes on it@dependabot squash and mergewill squash and merge this PR after your CI passes on it@dependabot cancel mergewill cancel a previously requested merge and block automerging@dependabot reopenwill reopen this PR if it is closed@dependabot closewill close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)