NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Maven Central
Maven Central, #750 by repository stars
jsoup is a Java library that simplifies working with real-world HTML and XML. It offers an easy-to-use API for URL fetching, data parsing, extraction, and manipulation using DOM API methods, CSS, and xpath selectors. jsoup implements the WHATWG HTML5 specification, and parses HTML to the same DOM as modern browsers.
Latest stable
1.24.1
Last release 22 days ago
03 Nov 2026
Ships fairly regularly
a new release about every 3 months
Some releases are documented
notes for 24 of 57 stable releases
Nothing withdrawn
no release was ever pulled
17 years old
57 releases · first in 2010
Drag across the ruler to compare, or tap a release to open it.
Removed APIs previously deprecated and scheduled for removal in 1.24.1. #2597
jsoup 1.24.1 is out now, with major improvements to CSS selectors and HTML parsing.
This release introduces an opt-in Web query mode, bringing selector behavior closer to CSS and browser DOM standards. It also adds new selectors and improves the correctness and performance of :has() queries. Web mode will become the default in 1.25.1; the selector migration guide explains how to get ready.
HTML parsing is now more closely aligned with the current HTML standard, including improvements to tables, formatting elements, templates, and customizable select elements. This release also adds processing instruction support, and includes a number of performance improvements and bug fixes.
There are some changes to existing behavior, including :root matching and limits on Response.bodyStream(). Please make sure to review the changes below before upgrading.
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.
System.setProperty("jsoup.queryMode", "web"). Queries return matching descendants only, can match surrounding ancestors, and follow HTML/XML case rules. Attribute ~= matches whitespace separated tokens instead of regexes.jsoup.queryMode=check to help prepare for Web mode. Selectors return legacy results and print differences to stderr, with caller locations to help identify affected code.:scope, :matchesAttr(name, regex), |= attribute matching, and attribute case flags i and s. These work in both legacy and Web modes, so queries can be updated before switching modes.ProcessingInstruction nodes. This supports marker nodes such as <?marker name="country-options"?>, matched by <template for="country-options"> in the HTML Standard's new declarative streaming syntax. Processing instructions can be selected with ::pi or ::pi(target), and their data can be read and changed through the node's attribute methods. Change: when using the XML parser, ordinary <?target ...?> nodes are now represented by ProcessingInstruction instead of XmlDeclaration; the <?xml ...?> declaration remains an XmlDeclaration. #2613Parser.parseAttributes(String) to parse an attribute fragment using that parser's settings.:has() selectors with child and sibling combinators now run faster by limiting the search to the parts of the document where they can match. This particularly improves selectors such as :has(> a), :has(+ dd), and :has(+ div span). #2610pathlength becomes pathLength) when parsing HTML. #2630Response.bodyStream() now observes the configured max body size and request timeout, consistent with the other response body methods. The default max size is 2 MB. You can configure that with maxBodySize(0) before executing the request to disable the cap. Response.isTruncated() reports when the decoded response content exceeded the configured limit. #2598:has(), :is(), and :not() expressions together. More complex queries throw SelectorParseException during parsing.Attributes.equals() and hashCode() now exclude internal attributes, such as source ranges and user data. #2633:root to match the tree's root element in both query modes. Previously, it matched the element the query was called on. Use :scope to refer to that element.- or _ now decode correctly in attribute values, matching HTML and browser behavior (e.g., ©- becomes ©-). #2588Response.bodyStream() when maxBodySize(0) is configured. #2593<table><b><p>X</b> places the paragraph before the table. #2601StreamParser now preserves its progress if you use the same Parser to parse another document, or call Element.append(String) on a streamed element. Previously, these operations replaced the active parse state and prevented streaming from continuing correctly. #2605:has() now correctly matches sibling alternatives and descendants of siblings. Given <div id=a></div><div><span></span></div>, both #a:has(+ div, > span) and #a:has(+ div span) select #a. #2610:not() now correctly applies :contains() and :matches() to the node value. For example, ::comment:not(:contains(foo)) excludes comments containing foo. #2610<select> parsing to the current HTML spec, retaining elements such as buttons and other markup that the previous rules discarded. #2611pre, listing, and textarea elements. Leading newlines in these elements' text are preserved when saving and reparsing HTML. #2616html(). #2619ConcurrentModificationException when emptying and reading separate childless elements concurrently. #2620command, device, and menuitem tags, as they are no longer in the HTML spec. #2621Node.before(Node) and Node.after(Node) now leave the document unchanged when given the node itself, instead of throwing a NullPointerException. #2628<dialog>, <main>, and <search> so their start and end tags close open paragraphs correctly. #2629</ COMMENT > to match the spec (<!-- COMMENT -->). #2631<body> and <frameset> start tags when the second open element is not body, matching the HTML spec. #2634<!---x and incomplete start tags such as <p id=, and improved their error reporting. #2636FormElement.empty() retaining associations with removed controls. If an input node removed by empty() was subsequently inserted outside its original form, it could incorrectly reappear in that form's elements() and formData() results. #2646My 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.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
jsoup 1.23.2 is out now. This release focuses largely on bug fixes, specification correctness, and performance improvements.
jsoup 1.23.2 is out now. This release focuses largely on bug fixes, specification correctness, and performance improvements.
It brings closer alignment with the HTML, XML, URL, and form submission specifications; improves XML and W3C DOM conversion; and makes HTTP workloads more efficient through streamed request bodies and broader JDK HttpClient reuse.
This version also includes new node insertion methods for Elements, and DOM mutations now reject operations that would create a cycle.
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.
StreamParser.selectFirst() calls during progressive parsing, so later matches are returned with their parsed contents when earlier selections had left them as parser lookahead. E.g., given <title>One</title><p id=hit>Full</p><p>Next</p>, selecting title and then #hit now advances the partial lookahead and returns <p id="hit">Full</p>, rather than returning an empty <p id="hit"></p> before its content is parsed. The updated readiness tracking follows StreamParser's normal emission order across implicit HTML structure and parser recovery. <small>#2551</small>W3CDom conversion performance for documents with many nested namespace declarations. The W3C converter now uses the same optimized namespace tracking as the XML parser. <small>#2559</small>W3CDom XML conversion to retain processing instructions, comments outside the root element, and CDATA sections, which were previously dropped or converted to text. <small>#2572</small>Elements#before(Node), after(Node), prepend(Node), and append(Node) to match the existing HTML string methods. <small>#953</small>Connection.requestBodyStream(InputStream) now stream directly with the JDK HttpClient on Java 11+, rather than being loaded fully into memory first. <small>#2575</small>Jsoup.newSession() to ordinary Jsoup.connect() calls, reducing transport thread and connection setup churn under sustained request loads. Sessions with custom authentication or SSL contexts continue to use their own client. <small>#2584</small>Parser#setMaxDepth(int) to configure. <small>#2570</small>W3CDom namespace conversion in several cases: <small>#2559</small>
a:b:c, are normalized. Attributes that still cannot be represented are skipped, and unrepresentable elements no longer change the surrounding tree.W3CDom conversion of programmatically created or renamed elements whose names can be represented in a jsoup HTML DOM but are not valid XML names, such as 1abc. These names are now normalized (e.g. _1abc) instead of causing a NullPointerException. <small>#2560</small>null elements or dropping attributes. For example, an attribute named 1a is written as _1a. Additional leading underscores keep repaired attribute names unique if they conflict with another attribute. <small>#2573</small>HttpClient implementation to accept responses missing a Content-Type header, matching the HttpURLConnection implementation. <small>#2549</small>+xml suffixes, including vendor-specific media types. <small>#2550</small>ValidationException. <small>#2555</small></body> remain children of the html element, while comments after </html> remain children of the document. <small>#2557</small>re2j regular expression engine, memory allocation errors caused by complex selector patterns at match time are now normalized to a ValidationException with a Pattern complexity error message.title/textarea content stays text through EOF, and custom text tags match exact names. <small>#2577</small></template> tags without throwing a ValidationException. <small>#2581</small>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 <a rel="me" href="https://tilde.zone/@jhy">follow me</a> (<b><a rel="me" href="https://tilde.zone/@jhy">@jhy@tilde.zone</a></b>) on Mastodon (Fediverse) to receive occasional notes about jsoup releases.
jsoup 1.23.1 is out now, with a faster and more memory-efficient HTML parser, improved alignment with the HTML standard across noscript, CDATA, SVG, a
jsoup 1.23.1 is out now, with a faster and more memory-efficient HTML parser, improved alignment with the HTML standard across noscript, CDATA, SVG, and MathML parsing, and safer, specification-correct HTTP redirects. The release also adds a fast immutable Element#classList(), direct outer-HTML output to an Appendable, and fixes across RCDATA parsing, XML conversion, tag-name handling, and Cleaner link detection.
Performance optimization was a major focus for this release. In our OpenJDK 21 benchmarks, ordinary string parsing is now 18% faster on average, parsing from an InputStream is 11% faster, and parsing with source position tracking is 70% faster while allocating 64% fewer bytes per document.
Source-tracked DOMs retain 58-65% less memory on representative medium-to-large documents, and the improvements hold under concurrent parsing without introducing new contention. Exact gains will naturally vary with document shape, JVM, and hardware.
This release also fixes a security issue in the Cleaner that could expose markup when malformed HTML is cleaned with a custom Safelist permitting certain raw-text elements. The built-in Safelists are unaffected.
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.
Parser#setTrackPosition(true)). Source ranges are now stored in compact parser-owned span records instead of node and attribute user data, and Position objects are created lazily when source ranges are read. This cuts tracked DOM retained size by about 50-60% on representative benchmark documents, while keeping Node#sourceRange(), Element#endSourceRange(), and Attribute#sourceRange() behavior intact. <small>#2498</small>Element#classList(), an immutable snapshot of an element's class names in attribute order. Use hasClass() when you just need to test for one class, classList() when you want to read or iterate classes without needing a mutable result, and classNames() when you want the existing mutable, deduplicated set that can be written back with classNames(Set). The class APIs now share an HTML-whitespace scanner, which also makes classNames() faster and lighter on allocation, especially when walking many elements without class names. <small>#2500</small>select, foreignObject, and template. <small>#2501</small><noscript> fallback markup is now parsed into an inspectable DOM subtree in both the document head and body. The fallback acts as a contained parsing island, so malformed markup cannot disrupt the surrounding document structure, while normal HTML tokenization still applies within it. This also improves round-trip serialization. <small>#2537</small>CookieStore continue to follow their configured scope. <small>#2540</small>Appendable with Node#outerHtml(Appendable), without first creating a String. This complements Element#html(Appendable), which appends inner HTML only. <small>#2532</small>re2j regular expression engine, stack overflows caused by complex selector patterns are now normalized to a ValidationException with a Pattern complexity error message. <small>#2548</small><title><p>Foo</TiTLE> and <textarea><img src=x></TeXtArEa> now keep the tag-shaped content as text instead of promoting it to markup. <small>#2503</small>W3CDom XML conversion so plain XML elements don't serialize with the reserved XML namespace as the default namespace. Explicit XML namespaces and xml:* attributes are still preserved. <small>#2504</small>Location is followed only for 301, 302, 303, 307, and 308 responses. Streamed request bodies are not buffered; if an automatic redirect requires replaying one, execution fails, so the caller can resend with a fresh stream. <small>#2540</small>rel=nofollow. <small>#2543</small>mvn clean verify drops from ~ 1m18s to ~ 21 seconds.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 <a rel="me" href="https://tilde.zone/@jhy">follow me</a> (<b><a rel="me" href="https://tilde.zone/@jhy">@jhy@tilde.zone</a></b>) on Mastodon / Fediverse to receive occasional notes about jsoup releases.
jsoup 1.22.2 is out now, with fixes and refinements across the library. It makes editing the DOM during traversal more predictable, refreshes the defa
jsoup 1.22.2 is out now, with fixes and refinements across the library. It makes editing the DOM during traversal more predictable, refreshes the default HTML tag definitions with newer elements and better text boundaries, and improves reliability in parsing and HTTP transport. The release also fixes a number of edge cases in cleaning, stream parsing, XML doctype handling, and Android packaging.
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.
NodeTraversor support for in-place DOM rewrites during NodeVisitor.head(). Current-node edits such as remove, replace, and unwrap now recover more predictably, while traversal stays within the original root subtree. This makes single-pass tree cleanup and normalization visitors easier to write, for example when unwrapping presentational elements or replacing text nodes as you walk the DOM. <small>#2472</small>Cleaner may be reused across concurrent threads, and that shared Safelist instances should not be mutated while in use. <small>#2473</small>TagSet for current HTML elements: added dialog, search, picture, and slot; made ins, del, button, audio, video, and canvas inline by default (Tag#isInline(), aligned to phrasing content in the spec); and added readable Element.text() boundaries for controls and embedded objects via the new Tag.TextBoundary option. This improves pretty-printing and keeps normalized text from running adjacent words together. <small>#2493</small>re2j dependency when not present. <small>#2459</small>NodeTraversor regression in 1.21.2 where removing or replacing the current node during head() could revisit the replacement node and loop indefinitely. The traversal docs now also clarify which inserted nodes are visited in the current pass. <small>#2472</small>available() call throws IOException, as seen on JDK 8 HttpURLConnection. <small>#2474</small>Cleaner no longer makes relative URL attributes in the input document absolute when cleaning or validating a Document. URL normalization now applies only to the cleaned output, and Safelist.isSafeAttribute() is side effect free. <small>#2475</small>Cleaner no longer duplicates enforced attributes when the input Document preserves attribute case. A case-variant source attribute is now replaced by the enforced attribute in the cleaned output. <small>#2476</small>HttpClient, because the JDK would silently ignore that proxy and attempt to connect directly. Those requests now fall back to the legacy HttpURLConnection transport instead, which does support SOCKS. <small>#2468</small>Connection.Response.streamParser() and DataUtil.streamParser(Path, ...) could fail on small inputs without a declared charset, if the initial 5 KB charset sniff fully consumed the input and closed it before the stream parse began. <small>#2483</small><!DOCTYPE root [<!ENTITY name "value">]>, now round-trip correctly. The subset is preserved as raw text only; entities are not expanded and external DTDs are not loaded. <small>#2486</small>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 <a rel="me" href="https://tilde.zone/@jhy">follow me</a> (<b><a rel="me" href="https://tilde.zone/@jhy">@jhy@tilde.zone</a></b>) on Mastodon / Fediverse to receive occasional notes about jsoup releases.
Set a removal schedule of jsoup 1.24.1 for previously deprecated APIs.
jsoup 1.22.1 is out now, adding support for the re2j regular 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.
re2j regular 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 the com.google.re2j dependency 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 calling Regex.usingRe2j(). <small>#2407</small>
Parser#unescape(String, boolean) that unescapes HTML entities using the parser's configuration (e.g. to support error tracking), complementing the existing static utility Parser.unescapeEntities(String, boolean). <small>#2396</small>Parser.setMaxDepth(). <small>#2421</small>Elements of an Element were not correctly invalidated in Node#replaceWith(Node), which could lead to incorrect results when subsequently calling Element#children(). <small>#2391</small>[attr=" foo "]). Now matches align with the CSS specification and browser engines. <small>#2380</small>ProxySelector.getDefault()) was ignored. Now, the system proxy is used if a per-request proxy is not set. <small>#2388</small>, <small>#2390</small>ValidationException could be thrown in the adoption agency algorithm with particularly broken input. Now logged as a parse error. <small>#2393</small>IndexOutOfBoundsException could be thrown when parsing a body fragment with crafted input. Now logged as a parse error. <small>#2397</small>, <small>#2406</small>parent child selector) 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. <small>#2411</small>Parser now preserves any custom TagSet applied to the parser. <small>#2422</small>, <small>#2423</small>Tag.Void now 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. <small>#2425</small><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. <small>#2387</small>, <small>#2439</small>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. <small>#2448</small>TagSet copies no longer mutate their template during lazy lookups, preventing cross-thread ConcurrentModificationException when parsing with shared sessions. <small>#2453</small><svg> foreignObject content nested within a <p>, which could incorrectly move the HTML subtree outside the SVG. <small>#2452</small>org.jsoup.internal.Functions (for removal in v1.23.1). This was previously used to support older Android API levels without full java.util.function coverage; jsoup now requires core library desugaring so this indirection is no longer necessary. <small>#2412</small>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 <a rel="me" href="https://tilde.zone/@jhy">follow me</a> (<b><a rel="me" href="https://tilde.zone/@jhy">@jhy@tilde.zone</a></b>) on Mastodon / Fediverse to receive occasional notes about jsoup releases.
Deprecated internal (yet visible) methods Normalizer#normalize(String, bool) and Attribute#shouldCollapseAttribute(Document.OutputSettings). These wil…
jsoup 1.21.2 is out now, adding support for custom SSLContext in HTTP/2 connections, and improving consistency in how user data is handled in attributes. It also brings performance gains in DOM manipulation and fragment parsing, and fixes several edge cases in stream parsing, traversal, cloning, and concurrent reads.
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.
Normalizer#normalize(String, bool) and Attribute#shouldCollapseAttribute(Document.OutputSettings). These will be removed in a future version.Connection#sslSocketFactory(SSLSocketFactory) in favor of the new Connection#sslContext(SSLContext). Using sslSocketFactory will force the use of the legacy HttpUrlConnection implementation, which does not support HTTP/2. <small>#2370</small>Connection.Response#statusMessage() to return a simple loggable string message (e.g. "OK") when using the HttpClient implementation, which doesn't otherwise return any server-set status message. <small>#2356</small>Attributes#size() and Attributes#isEmpty() now exclude any internal attributes (such as user data) from their count. This aligns with the attributes' serialized output and iterator. <small>#2369</small>Connection#sslContext(SSLContext) to provide a custom SSL (TLS) context to requests, supporting both the HttpClient and the legacy HttUrlConnection implementations. <small>#2370</small>element.child(0).remove(), and when using Parser#parseBodyFragement() to parse a large number of direct children. <small>#2373</small>.NodeTraversor, if a last child element was removed during the head() call, the parent would be visited twice. <small>#2355</small>.Attributes#size() and Attributes#isEmpty(). <small>#2356</small>Element#children() on the same element concurrently, a race condition could happen when the method was generating the internal child element cache (a filtered view of its child nodes). Since concurrent reads of DOM objects should be threadsafe without external synchronization, this method has been updated to execute atomically. <small>#2366</small>Removed previously deprecated methods. #2317
jsoup 1.21.1 is out now, featuring powerful new node selection capabilities that let you target specific DOM nodes like comments and text nodes using CSS selectors, dynamic tag customization through the new TagSet callback system, and improved defense against mutation XSS attacks with simplified attribute escaping. This release also brings HTTP/2 support by default, numerous API improvements for better developer experience, and fixes for several edge-case parsing issues.
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.
:matchText pseduo-selector due to its side effects on the DOM; use the new ::textnode selector and the Element#selectNodes(String css, Class<T> type) method instead. <small>#2343</small>Connection.Response#bufferUp() in lieu of Connection.Response#readFully() which can throw a checked IOException.Validate#ensureNotNull(Object) (replaced by typed Validate#expectNotNull(T)); protected HTML appenders from Attribute and Node.Selector to support direct matching against nodes such as comments and text nodes. For example, you can now find an element that follows a specific comment: ::comment:contains(prices) + p will select p elements immediately after a <!-- prices: --> comment. Supported types include ::node, ::leafnode, ::comment, ::text, ::data, and ::cdata. Node contextual selectors like ::node:contains(text), :matches(regex), and :blank are also supported. Introduced Element#selectNodes(String css) and Element#selectNodes(String css, Class<T> nodeType) for direct node selection. <small>#2324</small>TagSet#onNewTag(Consumer<Tag> customizer): register a callback that’s invoked for each new or cloned Tag when it’s inserted into the set. Enables dynamic tweaks of tag options (for example, marking all custom tags as self-closing, or everything in a given namespace as preserving whitespace). <small>#2330</small>TokenQueue and CharacterReader autocloseable, to ensure that they will release their buffers back to the buffer pool, for later reuse.Selector#evaluatorOf(String css), as a clearer way to obtain an Evaluator from a CSS query. An alias of QueryParser.parse(String css).TagSet) in a foreign namespace (e.g. SVG) can be configured to parse as data tags.NodeVisitor#traverse(Node) to simplify node traversal calls (vs. importing NodeTraversor).Connection.Response#readFully() as a replacement for Connection.Response#bufferUp() with an explicit IOException. Similarly, added Connection.Response#readBody() over Connection.Response#body(). Deprecated Connection.Response#bufferUp(). <small>#2327</small>< and > characters are now escaped in attributes. This helps prevent a class of mutation XSS attacks. <small>#2337</small>Connection to prefer using the JDK's HttpClient over HttpUrlConnection, if available, to enable HTTP/2 support by default. Users can disable via -Djsoup.useHttpClient=false. <small>#2340</small>script in a svg foreign context should be parsed as script data, not text. <small>#2320</small>Tag#isFormSubmittable() was updating the Tag's options. <small>#2323</small>The following internal components have been deprecated. If you do happen to be using any of these, please take the opportunity now to migrate away fro…
<foo />) to close HTML elements by default. Foreign content (SVG, MathML), and content parsed with the XML parser, still supports self-closing tags. If you need specific HTML tags to support self-closing, you can register a custom tag via
the TagSet configured in Parser.tagSet(), using Tag#set(Tag.SelfClose). Standard void tags (such as <img>, <br>, etc.) continue to behave as usual and are not affected by this
change. #2300.ChangeNotifyingArrayList, Document.updateMetaCharsetElement(), Document.updateMetaCharsetElement(boolean), HtmlTreeBuilder.isContentForTagData(String), Parser.isContentForTagData(String), Parser.setTreeBuilder(TreeBuilder), Tag.formatAsBlock(), Tag.isFormListed(), TokenQueue.addFirst(String), TokenQueue.chompTo(String), TokenQueue.chompToIgnoreCase(String), TokenQueue.consumeToIgnoreCase(String), TokenQueue.consumeWord(), TokenQueue.matchesAny(String...)TagSet tag collection. Their properties can impact both the parse and how content is serialized (output as HTML or XML). #2285.Element.cssSelector() will prefer to return shorter selectors by using ancestor IDs when available and unique. E.g. #id > div > p instead of html > body > div > div > p #2283.Elements.deselect(int index), Elements.deselect(Object o), and Elements.deselectAll() methods to remove elements from the Elements list without removing them from the underlying DOM. Also added Elements.asList() method to get a modifiable list of elements without affecting the DOM. (Individual Elements remain linked to the DOM.) #2100.Connection.requestBodyStream(InputStream stream). #1122.Tag#prefix(), Tag#localName(), Attribute#prefix(), Attribute#localName(), and Attribute#namespace() to retrieve these. #2299.Element#cssSelector() will emit appropriately escaped selectors, and the QueryParser supports those. Added Selector.escapeCssIdentifier() and ` Selector.unescapeCssIdentifier(). #2297, #2305QueryParser into a clearer recursive descent parser. #2310.div >> p) will throw an explicit parse exception. #2311.Parser instances threadsafe, so that inadvertent use of the same instance across threads will not lead to errors. For actual concurrency, use Parser#newInstance() per thread. #2314.Document to the W3C DOM in W3CDom, elements with an attribute in an undeclared namespace now get a declaration of xmlns:prefix="undefined". This allows subsequent serialization to XML via W3CDom.asString() to succeed. #2087.StreamParser could emit the final elements of a document twice, due to how onNodeCompleted was fired when closing out the stack. #2295.? in <?xml version="1.0"?> would incorrectly emit an error. #2298.Element#cssSelector() on an element with combining characters in the class or ID now produces the correct output. #1984.Removed previously deprecated class: org.jsoup.UncheckedIOException (replace with java.io.UncheckedIOException); moved previously deprecated method El…
Jsoup.connect(), when running on Java 11+, via the Java HttpClient
implementation. #2257.
System.setProperty("jsoup.useHttpClient", "true"); to enable making requests via the HttpClient instead ,
which will enable http/2 support, if available. This will become the default in a later version of jsoup, so now is
a good time to validate it.HttpClient impl is not available in your JRE, requests will continue to be made via
HttpURLConnection (in http/1.1 mode).org.jsoup.UncheckedIOException (replace with java.io.UncheckedIOException);
moved previously deprecated method Element Element#forEach(Consumer) to
void Element#forEach(Consumer()). #2246Document#updateMetaCharsetElement(bool) and #Document#updateMetaCharsetElement(), as the
setting had no effect. When Document#charset(Charset) is called, the document's meta charset or XML encoding
instruction is always set. #2247Safelist that preserves relative links, the isValid() method will now consider these
links valid. Additionally, the enforced attribute rel=nofollow will only be added to external links when configured
in the safelist. #2245Element#selectStream(String query) and Element#selectStream(Evaluator) methods, that return a Stream of
matching elements. Elements are evaluated and returned as they are found, and the stream can be
terminated early. #2092Element objects now implement Iterable, enabling them to be used in enhanced for loops.Reader via
Parser#parseFragmentInput(Reader, Element, String). #1177jsoup-examples.jar. #1702#id .class (and other similar descendant queries) by around 4.6x, by better
balancing the Ancestor evaluator's cost function in the query
planner. #2254<isindex> tags, which would autovivify a form element with labels. This is no
longer in the spec.Elements.selectFirst(String cssQuery) and Elements.expectFirst(String cssQuery), to select the first
matching element from an Elements list. #2263!. #2275< are normalized to _ to ensure valid
XML. For example, <foo<bar> becomes <foo_bar>, as XML does not allow < in element names, but HTML5
does. #2276; in an attribute name, it could not be converted to a W3C DOM element, and so subsequent XPath
queries could miss that element. Now, the attribute name is more completely
normalized. #2244Connection, skip cookies that have no name, rather than throwing a validation
exception. #2242java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;
could be thrown when calling Response#body() after parsing from a URL and the buffer size was
exceeded. #2250null InputStream inputs to Jsoup.parse(InputStream stream, ...), by returning
an empty Document. #2252template tag containing an li within an open li would be parsed incorrectly, as it was not recognized as a
"special" tag (which have additional processing rules). Also, added the SVG and MathML namespace tags to the list of
special tags. #2258template tag containing a button within an open button would be parsed incorrectly, as the "in button scope"
check was not aware of the template element. Corrected other instances including MathML and SVG elements,
also. #2271:nth-child selector with a negative digit-less step, such as :nth-child(-n+2), would be parsed incorrectly as a
positive step, and so would not match as expected. #1147doc.charset(charset) on an empty XML document would throw an
IndexOutOfBoundsException. #2266StructuralEvaluator (e.g., a selector ancestor chain like A B C) by
ensuring cache reset calls cascade to inner members. #2277doc.clone().append(html) were not supported. When a document was cloned, its Parser was not cloned but was a shallow copy of the original parser. #22811.18.3 is a quick release to fix #2235 in 1.18.2.
1.18.3 is a quick release to fix #2235 in 1.18.2.
Please see also the full release notes for jsoup 1.18.2 if you are coming from an earlier release.
-, ., or digits were incorrectly considered invalid and removed. #2235-, ., or digits were incorrectly marked as invalid and
removed. 2235Optimized the throughput and memory use throughout the input read and parse flows, with heap allocations and GC down between -6% and -89%, and through
byte[] and char[] arrays used to read and parse the input. 2186html() and Entities.escape() when the input contains UTF characters in a supplementary plane, by around 49%. 2183FormElement.elements() now reflect changes made to the DOM, subsequently to the original parse. 2140TreeBuilder, the onNodeInserted() and onNodeClosed() events are now also fired for the outermost / root Document node. This enables source position tracking on the Document node (which was previously unset). And it also enables the node traversor to see the outer Document node. 2182Elements#set(). 2212Element.cssSelector() would fail if the element's class contained a * character. 2169html, it should be parsed in Quirks Mode. 2197div:has(span + a), the has() component was not working correctly, as the inner combining query caused the evaluator to match those against the outer's siblings, not children. 2187:has() components in a nested :has() might incorrectly execute. 2131Connection.Response#cookies() will provide the last one set. Generally it is better to use the Jsoup.newSession method to maintain a cookie jar, as that applies appropriate path selection on cookies when making requests. 1831html or body). 2204< as part of a tag name, instead of emitting it as a character node. 2230< as the start of an attribute name, vs creating a new element. The previous behavior was intended to parse closer to what we anticipated the author's intent to be, but that does not align to the spec or to how browsers behave. 1483Removed previously deprecated internal classes and methods. 2094
https://jsoup.org/news/release-1.18.1
StreamParser provides a progressive parse of its input. As each Element is completed, it is
emitted via a Stream or Iterator interface. Elements returned will be complete with all their children, and an
(empty) next sibling, if applicable. Elements (or their children) may be removed from the DOM during the parse,
for e.g. to conserve memory, providing a mechanism to parse an input document that would otherwise be too large to fit
into memory, yet still providing a DOM interface to the document and its elements. Additionally, the parser provides
a selectFirst(String query) / selectNext(String query), which will run the parser until a hit is found, at which
point the parse is suspended. It can be resumed via another select() call, or via the stream() or iterator()
methods. 2096Path accepting parse methods: Jsoup.parse(Path), Jsoup.parse(path, charsetName, baseUri, parser),
etc. 2055button tag configuration to include a space between multiple button elements in the Element.text()
method. 2105ns|* all elements in namespace Selector. 1811_, vs being
stripped. This should make the process clearer, and generally prevent an invalid attribute name being coerced
unexpectedly. 2143-1. 2106{, } in the path, a Malformed URL exception would
be thrown (if in development), or the URL might otherwise not be escaped correctly (if in
production). The URL encoding process has been improved to handle these characters
correctly. 2142W3CDom with a custom output Document, a Null Pointer Exception would be
thrown. 2114:has() selector did not match correctly when using sibling combinators (like
e.g.: h1:has(+h2)). 2137:empty selector incorrectly matched elements that started with a blank text node and were followed by
non-empty nodes, due to an incorrect short-circuit. 2130Element.cssSelector() would fail with "Did not find balanced marker" when building a selector for elements that had
a ( or [ in their class names. And selectors with those characters escaped would not match as
expected. 2146Entities.escape(string) to make the escaped text suitable for both text nodes and attributes (previously was
only for text nodes). This does not impact the output of Element.html() which correctly applies a minimal escape
depending on if the use will be for text data or in a quoted
attribute. 1278<base href> URL, in the normalizing regex.
2165Attribute object accessors: Added Element.attribute(String) and Attributes.attribute(String) to more simply obtain an Attribute object. 2069
Element.attribute(String) and Attributes.attribute(String) to more simply
obtain an Attribute object. 2069Attribute.setKey(String)), the source range is now still tracked
in Attribute.sourceRange(). 2070[*] element with any attribute selector. And also restored
support for selecting by an empty attribute name prefix ([^]). 2079parent [attr=va], other, the , OR was binding
to [attr=va] instead of parent [attr=va], causing incorrect selections. The fix includes a EvaluatorDebug class
that generates a sexpr to represent the query, allowing simpler and more thorough query parse
tests. 2073:has evaluator held a non-thread-safe Iterator, and so if an Evaluator object was
shared across multiple concurrent threads, a NoSuchElement exception may be thrown, and the selected results may be
incorrect. Now, the iterator object is a thread-local. 2088jsoup 1.17.1 is out now with support for request-level authentication, attribute name & value source ranges, stream() iterable support, and a bunch of
<p><b>jsoup 1.17.1</b> is out now with support for request-level authentication, attribute name & value source ranges, stream() iterable support, and a bunch of other improvements and bug fixes.</p>
<p>Many thanks to everyone who contributed to this release!</p>
<h2>Improvements</h2> <ul> <li><b>Request-Level Authentication</b>: Added support for request-level authentication in Jsoup.connect(), enabling authentication to proxies and servers. <small><a href="https://github.com/jhy/jsoup/pull/2046">More.</a></small></li> </ul> <ul> <li><b>Elements DOM Mutators</b>: In the <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html" title="A list of Elements, with methods that act on every element in the list.">Elements</a></code> list, added direct support for <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#set(int,org.jsoup.nodes.Element)" title="Replace the Element at the specified index in this list, and in the DOM.">Elements#set(int, Element)</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#remove(int)" title="Remove the Element at the specified index in this ist, and from the DOM.">Elements#remove(int)</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#remove(java.lang.Object)" title="Remove the specified Element from this list, and from th DOM">Elements#remove(Object)</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#clear()" title="Removes all the elements from this list, and each of them from the DOM.">Elements#clear()</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#removeAll(java.util.Collection)" title="Removes from this list, and from the DOM, each of the elements that are contained in the specified collection and are in this list.">Elements#removeAll()</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#retainAll(java.util.Collection)" title="Retain in this list, and in the DOM, only the elements that are in the specified collection and are in this list.">Elements#retainAll()</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#removeIf(java.util.function.Predicate)" title="Remove from the list, and from the DOM, all elements in this list that mach the given filter.">Elements#removeIf()</a></code>, <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#replaceAll(java.util.function.UnaryOperator)" title="Replace each element in this list with the result of the operator, and update the DOM.">Elements#replaceAll()</a></code>. These methods update the original DOM, as well as the Elements list. <small><a href="https://github.com/jhy/jsoup/pull/2017">More.</a></small></li> </ul> <ul> <li><b>Stream Interface</b>: Introduced the <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/NodeIterator.html" title="Iterate through a Node and its tree of descendants, in document order, and returns nodes of the specified type.">NodeIterator</a></code> class for efficient node tree traversal using the Iterator interface. Added Stream <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Element.html#stream()" title="Returns a Stream of this Element and all of its descendant Elements.">Element#stream()</a></code> and <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Node.html#nodeStream()" title="Returns a Stream of this Node and all of its descendant Nodes.">Node#nodeStream()</a></code> methods for fluent composable stream pipelines of node traversals. <small><a href="https://github.com/jhy/jsoup/pull/2051">More.</a></small></li> </ul> <ul> <li><b>XML OutputSettings</b>: Automatically sets the xhtml <code>EscapeMode</code> as default when changing the <code>OutputSettings</code> syntax to <code>XML</code>.</li> </ul> <ul> <li><b>is() Selector</b>: Added the <code>:is(selector list)</code> pseudo-selector to find elements that match any selectors in the selector list. This enhances readability for large <code>OR</code>ed selectors. <small><a href="//jsoup.org/apidocs/org/jsoup/select/Selector.html">More.</a></small></li> </ul> <ul> <li><b>JPMS Module Support</b>: Repackaged the library with native JPMS module support. <small><a href="https://github.com/jhy/jsoup/pull/2025">More.</a></small></li> </ul> <ul> <li><b>Source Position Fidelity</b>: Improved fidelity of source positions when tracking is enabled. Implicitly created or closed elements are now trackable via <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Range.html#isImplicit()" title="Checks if the range represents a node that was implicitly created / closed.">Range.isImplicit()</a></code>. <small><a href="https://github.com/jhy/jsoup/pull/2056">More.</a></small></li> </ul> <ul> <li><b>Attribute Source Positions</b>: Enabled source position for attribute names and values when source tracking is on. <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Attribute.html#sourceRange()" title="Get the source ranges (start to end positions) in the original input source from which this attribute's name and value were parsed.">Attribute#sourceRange()</a></code> provides the ranges. <small><a href="https://github.com/jhy/jsoup/pull/2057">More.</a></small></li> </ul> <ul> <li><b>Virtual Threads</b>: Enhanced performance under Java 21+ Virtual Threads by replacing the internal <code>ConstrainableInputStream</code> with <code>ControllableInputStream</code>. <small><a href="https://github.com/jhy/jsoup/issues/2054">More.</a></small></li> </ul> <ul> <li><b>XML Mimetype Support</b>: Extended XML mimetype support in <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect()</a></code> to include any XML mimetype. <small><a href="https://github.com/jhy/jsoup/issues/2059">More.</a></small></li> </ul> <h2>Bug Fixes</h2> <ul> <li><b>XML Data Nodes</b>: Fixed a bug where HTML elements parsed as data nodes were not correctly emitted as <code>CDATA</code> nodes when outputting with <code>XML</code> syntax. <small><a href="https://github.com/jhy/jsoup/pull/1720">More.</a></small></li> </ul> <ul> <li><b>Immediate Parent Selector</b>: Corrected a bug where the Immediate Parent selector <code>></code> could match elements above the root context element. <small><a href="https://github.com/jhy/jsoup/issues/2018">More.</a></small></li> </ul> <ul> <li><b>Sub-Query Parsing</b>: Resolved a bug where combinators following the <code>,</code> Or combinator in a sub-query were incorrectly skipped. <small><a href="https://github.com/jhy/jsoup/issues/1707">More.</a></small></li> </ul> <ul> <li><b>Empty Doctype</b>: Fixed a bug in <code><a href="//jsoup.org/apidocs/org/jsoup/helper/W3CDom.html" title="Helper class to transform a Document to a org.w3c.dom.Document, for integration with toolsets that use the W3C DOM.">W3CDom</a></code> where the conversion would fail if the jsoup input document contained an empty doctype. The doctype is now discarded, and the conversion continues.</li> </ul> <ul> <li><b>SVG Elements Cleaning</b>: Fixed incorrect nesting when cleaning a document containing SVG elements or other foreign elements with preserved-case names. <small><a href="https://github.com/jhy/jsoup/issues/2049">More.</a></small></li> </ul> <ul> <li><b>Unknown Self-Closing Tags</b>: Preserved the output style of unknown self-closing tags from the input when cleaning a document. <small><a href="https://github.com/jhy/jsoup/issues/2049">More.</a></small></li> </ul> <h2>Build Improvements</h2> <ul> <li><b>Local Test Proxy</b>: Added a local test proxy implementation for proxy integration tests. <small><a href="https://github.com/jhy/jsoup/pull/2029">More.</a></small></li> </ul> <ul> <li><b>HTTPS Request Tests</b>: Added tests for HTTPS request support using a local self-signed certificate. Includes proxy tests. <small><a href="https://github.com/jhy/jsoup/pull/2032">More.</a></small></li> </ul> <h2>Changes</h2> <ul> <li><b>Response BodyStream</b>: The InputStream returned in <code><a href="//jsoup.org/apidocs/org/jsoup/Connection.Response.html#bodyStream()" title="Get the body of the response as a (buffered) InputStream.">Connection.Response.bodyStream()</a></code> is now a plain <code>BufferedInputStream</code>. <small><a href="https://github.com/jhy/jsoup/issues/2054">More.</a></small></li> </ul>
Removed previously deprecated methods Document.normalise() , Element.forEach(org.jsoup.helper.Consumer<>) , Node.forEach(org.jsoup.helper.Consumer<>)…
<h2>Improvements</h2> <ul> <li>Optimized the performance of complex CSS selectors, by adding a cost-based query planner. Evaluators are sorted by their relative execution cost, and executed in order of lower to higher cost. This speeds the matching process by ensuring that simpler evaluations (such as a tag name match) are conducted prior to more complex evaluations (such as an attribute regex, or a deep child scan with a :has).</li> </ul> <ul> <li>Added support for <code><svg></code> and <code><math></code> tags (and their children). This includes tag namespaces and case preservation on applicable tags and attributes. <code><a href="https://github.com/jhy/jsoup/pull/2008">#2008</a></code></li> </ul> <ul> <li>When converting jsoup Documents to W3C Documents in <code><a href="//jsoup.org/apidocs/org/jsoup/helper/W3CDom.html" title="Helper class to transform a Document to a org.w3c.dom.Document, for integration with toolsets that use the W3C DOM.">W3CDom</a></code>, HTML documents will be placed in the <code>http://www.w3.org/1999/xhtml</code> namespace by default, per the HTML5 spec. This can be controlled by setting <code><a href="//jsoup.org/apidocs/org/jsoup/helper/W3CDom.html#namespaceAware(boolean)" title="Update the namespace aware setting.">W3CDom#namespaceAware(boolean false)</a></code>. <code><a href="https://github.com/jhy/jsoup/pull/1848">#1848</a></code></li> </ul> <ul> <li>Speed optimized the Structural Evaluators by memoizing previous evaluations. Particularly the <code>~</code> (any preceding sibling) and <code>:nth-of-type</code> selectors are improved. <code><a href="https://github.com/jhy/jsoup/issues/1956">#1956</a></code></li> </ul> <ul> <li>Tweaked the performance of the <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Element.html" title="An HTML Element consists of a tag name, attributes, and child nodes (including text nodes and other elements).">Element</a></code> <code>nextElementSibling</code>, <code>previousElementSibling</code>, <code>firstElementSibling</code>, <code>lastElementSibling</code>, <code>firstElementChild</code>, and `lastElementChild. They now inplace filter/skip in the child-node list, vs having to allocate and scan a complete Element filtered list.</li> </ul> <ul> <li>Optimized internal methods that previously called <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Element.html#children()" title="Get this element's child elements.">Element.children()</a></code> to use filter/skip child-node list accessors instead, reducing new Element List allocations.</li> </ul> <ul> <li>Tweaked the performance of parsing <code>:pseudo</code> selectors.</li> </ul> <ul> <li>When using the <code>:empty</code> pseudo-selector, blank textnodes are now considered empty. Previously, an element containing any whitespace was not considered empty. <code><a href="https://github.com/jhy/jsoup/issues/1976">#1976</a></code></li> </ul> <ul> <li>In forms, <code><input type="image"></code> should be excluded from <code>Element.formData()</code> (and hence from form submissions). <code><a href="https://github.com/jhy/jsoup/pull/2010">#2010</a></code></li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/safety/Safelist.html" title="Safe-lists define what HTML (elements and attributes) to allow through the cleaner.">Safelist</a></code>, made <code>isSafeTag()</code> and <code>isSafeAttribute()</code> public methods, for extensibility. <code><a href="https://github.com/jhy/jsoup/issues/1780">#1780</a></code></li> </ul> <h2>Bug Fixes</h2> <ul> <li>Bugfix: <code>form</code> elements and empty elements (such as <code>img</code>) did not have their attributes de-duplicated. <code><a href="https://github.com/jhy/jsoup/pull/1950">#1950</a></code></li> </ul> <ul> <li>If <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Document.OutputSettings.html" title="A Document's output settings control the form of the text() and html() methods.">Document.OutputSettings</a></code> was cloned from a clone, an NPE would be thrown when used. <code><a href="https://github.com/jhy/jsoup/pull/1964">#1964</a></code></li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect(String url)</a></code>, URL paths containing a %2B were incorrectly recoded to a '+', or a '+' was recoded to a ' '. Fixed by reverting to the previous behavior of not encoding supplied paths, other than normalizing to ASCII. <code><a href="https://github.com/jhy/jsoup/issues/1952">#1952</a></code></li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect(String url)</a></code>, strings containing supplemental characters (e.g. emoji) were not URL escaped correctly.</li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect(String url)</a></code>, the ConstrainableInputStream would clear Thread interrupts when reading the body. This precluded callers from spawning a thread, running a number of requests for a length of time, then joining that thread after interrupting it. <code><a href="https://github.com/jhy/jsoup/issues/1991">#1991</a></code></li> </ul> <ul> <li>When tracking HTML source positions, the closing tags for <code>H1</code>...<code>H6</code> elements were not tracked correctly. <code><a href="https://github.com/jhy/jsoup/issues/1987">#1987</a></code></li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect()</a></code>, a <code><a href="//jsoup.org/apidocs/org/jsoup/Connection.Method.html#DELETE">DELETE</a></code> method request did not support a request body. <code><a href="https://github.com/jhy/jsoup/issues/1972">#1972</a></code></li> </ul> <ul> <li>When calling <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Element.html#cssSelector()" title="Get a CSS selector that will uniquely select this element.">Element.cssSelector()</a></code> on an extremely deeply nested element, a <code>StackOverflowError</code> could occur. Further, a <code>StackOverflowError</code> may occur when running the query. <code><a href="https://github.com/jhy/jsoup/issues/2001">#2001</a></code></li> </ul> <ul> <li>Appending a node back to its original <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Element.html" title="An HTML Element consists of a tag name, attributes, and child nodes (including text nodes and other elements).">Element</a></code> after <code><a href="//jsoup.org/apidocs/org/jsoup/select/Elements.html#empty()" title="Empty (remove all child nodes from) each matched element.">empty()</a></code> would throw an Index out of bounds exception. Also, now the child nodes that were removed have their parent node cleared, fully detaching them from the original parent. <code><a href="https://github.com/jhy/jsoup/issues/2013">#2013</a></code></li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Connection.html" title="The Connection interface is a convenient HTTP client and session object to fetch content from the web, and parse them into Documents.">Connection</a></code> when adding headers, the value may have been assumed to be an incorrectly decoded <code>ISO_8859_1</code> string, and re-encoded as <code>UTF-8</code>. The value is now left as-is.</li> </ul> <h2>Changes</h2> <ul> <li>Removed previously deprecated methods <code>Document.normalise()</code>, <code>Element.forEach(org.jsoup.helper.Consumer<>)</code>, <code>Node.forEach(org.jsoup.helper.Consumer<>)</code>, and the <code>org.jsoup.helper.Consumer</code> interface; the latter being a previously required compatibility shim prior to Android's de-sugaring support.</li> </ul> <ul> <li>The previous compatibility shim <code><a href="//jsoup.org/apidocs/org/jsoup/UncheckedIOException.html" title="Deprecated. Use UncheckedIOException instead. This class acted as a compatibility shim for Java versions prior to 1.8.">org.jsoup.UncheckedIOException</a></code> is deprecated in favor of the now supported <code>java.io.UncheckedIOException</code>. If you are catching the former, modify your code to catch the latter instead. <code><a href="https://github.com/jhy/jsoup/pull/1989">#1989</a></code></li> </ul> <ul> <li>Blocked <code>noscript</code> tags from being added to Safelists, due to incompatibilities between parsers with and without script-mode enabled.</li> </ul> <p></p>
jsoup Java HTML Parser release 1.16.1
<h1>jsoup Java HTML Parser release 1.16.1</h1>
<h2>Improvements</h2> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect(String url)</a></code>, natively support URLs with Unicode characters in the path or query string, without having to be escaped by the caller. <a href="https://github.com/jhy/jsoup/issues/1914">#1914</a></li> </ul> <ul> <li>Calling <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Node.html#remove()" title="Remove (delete) this node from the DOM tree.">Node.remove()</a></code> on a node with no parent is now a no-op, vs a validation error. <a href="https://github.com/jhy/jsoup/issues/1898">#1898</a></li> </ul> <h2>Bug Fixes</h2> <ul> <li>Aligned the HTML Tree Builder processing steps for <code>AfterBody</code> and <code>AfterAfterBody</code> to the updated WHATWG standard, to not pop the stack to close <code><body></code> or <code><html></code> elements. This prevents an errant <code></html></code> closing the preceding structure. Also added appropriate error message outputs in this case. <a href="https://github.com/jhy/jsoup/issues/1851">#1851</a></li> </ul> <ul> <li>Corrected support for ruby elements (<code><ruby></code>, <code><rp></code>, <code><rt></code>, and <code><rtc></code>) to current spec. <a href="https://github.com/jhy/jsoup/issues/1294">#1294</a></li> </ul> <ul> <li>When using <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Node.html#before(org.jsoup.nodes.Node)" title="Insert the specified node into the DOM before this node (as a preceding sibling).">Node.before(Node)</a></code> or <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Node.html#after(org.jsoup.nodes.Node)" title="Insert the specified node into the DOM after this node (as a following sibling).">Node.after(Node)</a></code>, if the incoming node was a sibling of the context node, the incoming node may be inserted into the wrong relative location. <a href="https://github.com/jhy/jsoup/issues/1898">#1898</a></li> </ul> <ul> <li>In <code><a href="//jsoup.org/apidocs/org/jsoup/Jsoup.html#connect(java.lang.String)" title="Creates a new Connection (session), with the defined request URL.">Jsoup.connect(String url)</a></code>, if the input URL had components that were already <code>%</code> escaped, they would be escaped again, causing errors when fetched. <a href="https://github.com/jhy/jsoup/issues/1902">#1902</a></li> </ul> <ul> <li>When tracking input source positions, text in tables that was fostered had invalid positions. <a href="https://github.com/jhy/jsoup/issues/1927">#1927</a></li> </ul> <ul> <li>If the <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Document.OutputSettings.html" title="A Document's output settings control the form of the text() and html() methods.">Document.OutputSettings</a></code> class was initialized, and then <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Entities.html#escape(java.lang.String)" title="HTML escape an input string, using the default settings (UTF-8, base entities).">Entities.escape(String)</a></code> called, an NPE may be thrown due to a class loading circular dependency. <a href="https://github.com/jhy/jsoup/issues/1910">#1910</a></li> </ul> <ul> <li>When pretty-printing, the first inline <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Element.html" title="An HTML Element consists of a tag name, attributes, and child nodes (including text nodes and other elements).">Element</a></code> or <code><a href="//jsoup.org/apidocs/org/jsoup/nodes/Comment.html" title="A comment node.">Comment</a></code> in a block would not be wrap-indented if it were preceded by a blank text node. <a href="https://github.com/jhy/jsoup/issues/1906">#1906</a></li> </ul> <ul> <li>When pretty-printing a <code><pre></code> containing block tags, those tags were incorrectly indented. <a href="https://github.com/jhy/jsoup/issues/1891">#1891</a></li> </ul> <ul> <li>When pretty-printing nested inlineable blocks (such as a <code><p></code> in a <code><td></code>), the inner element should be indented. <a href="https://github.com/jhy/jsoup/issues/1926">#1926</a></li> </ul> <ul> <li><code><br></code> tags should be wrap-indented when in block tags (and not when in inline tags). <a href="https://github.com/jhy/jsoup/issues/1911">#1911</a></li> </ul> <ul> <li>The contents of a sufficiently large <code><textarea></code> with un-escaped HTML closing tags may be incorrectly parsed to an empty node. <a href="https://github.com/jhy/jsoup/issues/1929">#1929</a></li> </ul>
Subsequently, the latter has been deprecated. #1870
<h1>jsoup Java HTML Parser release 1.15.4</h1> <p><b>jsoup 1.15.4</b> is out now, and includes a bunch of improvements, particularly when pretty-printing HTML, and bug fixes.</p> <p><b>jsoup</b> is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of HTML5 DOM methods and CSS selectors.</p> <p><a href="https://jsoup.org/download"><b>Download</b></a> jsoup now.</p> <h2>Improvements</h2> <ul> <li>Added the ability to escape CSS selectors (tags, IDs, classes) to match elements that don't follow regular CSS syntax. For example, to match by classname <code><p class="one.two"></code>, use <code>document.select("p.one\.two");</code> <a href="https://github.com/jhy/jsoup/issues/838">#838</a></li> </ul> <ul> <li>When pretty-printing, wrap text that follows a <code><br></code> tag. <a href="https://github.com/jhy/jsoup/issues/1858">#1858</a></li> </ul> <ul> <li>When pretty-printing, normalize newlines that follow self-closing tags in custom tags. <a href="https://github.com/jhy/jsoup/issues/1852">#1852</a></li> </ul> <ul> <li>When pretty-printing, collapse non-significant whitespace between a block and an inline tag. <a href="https://github.com/jhy/jsoup/issues/1802">#1802</a></li> </ul> <ul> <li>In <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Element.html#forEach(java.util.function.Consumer)" title="Perform the supplied action on this Element and each of its descendant Elements, during a depth-first traversal.">Element.forEach()</a></code> and <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Node.html#forEachNode(java.util.function.Consumer)" title="Perform the supplied action on this Node and each of its descendants, during a depth-first traversal.">Node.forEachNode()</a></code>, use <code>java.util.function.Consumer</code> instead of the previous Android compatibility shim <code><a href="https://jsoup.org/apidocs/org/jsoup/helper/Consumer.html" title="Deprecated. Use Consumer instead. This interface will be removed in the next release. If you are targeting Android, see how to enable desugaring.">org.jsoup.helper.Consumer</a></code>. Subsequently, the latter has been deprecated. <a href="https://github.com/jhy/jsoup/pull/1870">#1870</a></li> </ul> <ul> <li>Added a new method <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Document.html#forms()" title="Get each of the <form> elements contained in this document.">Document.forms()</a></code>, to conveniently retrieve a <code>List<FormElement></code> containing the <code><form></code> elements in a document.</li> </ul> <ul> <li>Added a new method <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Document.html#expectForm(java.lang.String)" title="Selects the first FormElement in this document that matches the query.">Document.expectForm()</a></code>, to find the first matching <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/FormElement.html" title="A HTML Form Element provides ready access to the form fields/controls that are associated with it.">FormElement</a></code>, or blow up trying.</li> </ul> <h2>Bug Fixes</h2> <ul> <li>URLs containing characters such as <code><a href="</code>">and <code></a></code> were not escaped correctly, and would throw a <code>MalformedURLException</code> when fetched. <a href="https://github.com/jhy/jsoup/issues/1873">#1873</a></li> </ul> <ul> <li><code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Element.html#cssSelector()" title="Get a CSS selector that will uniquely select this element.">Element.cssSelector()</a></code> would create invalid selectors for elements where the tag name, ID, or classnames needed to be escaped (e.g. if a class name contained a <code>:</code> or <code>.</code>). <a href="https://github.com/jhy/jsoup/issues/1742">#1742</a></li> </ul> <ul> <li><code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Element.html#text()" title="Gets the normalized, combined text of this element and all its children.">Element.text()</a></code> should have a space between a block and an inline element. <a href="https://github.com/jhy/jsoup/issues/1877">#1877</a></li> </ul> <ul> <li>If a <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Node.html" title="The base, abstract Node model.">Node</a></code> or an <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Element.html" title="An HTML Element consists of a tag name, attributes, and child nodes (including text nodes and other elements).">Element</a></code> was replaced with itself, that node would incorrectly be orphaned. <a href="https://github.com/jhy/jsoup/issues/1843">#1843</a></li> </ul> <ul> <li>Form data on a previous request was copied to a new request in <code><a href="https://jsoup.org/apidocs/org/jsoup/helper/HttpConnection.html#newRequest()">newRequest()</a></code>, resulting in an accumulation of form data when executing multi-step form submissions, or data sent to later requests incorrectly. Now, <code><a href="https://jsoup.org/apidocs/org/jsoup/helper/HttpConnection.html#newRequest()">newRequest()</a></code> only copies session related settings (cookies, proxy settings, user-agent, etc) but not the request data nor the body. <a href="https://github.com/jhy/jsoup/issues/1778">#1778</a></li> </ul> <ul> <li>Fixed an issue in <code><a href="https://jsoup.org/apidocs/org/jsoup/safety/Safelist.html#removeAttributes(java.lang.String,java.lang.String...)" title="Remove a list of allowed attributes from a tag.">Safelist.removeAttributes()</a></code> which could throw a <code>ConcurrentModificationException</code> when using the <code>:all</code> pseudo-attribute.</li> </ul> <ul> <li>Given extremely deeply nested HTML, a number of methods in <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Element.html" title="An HTML Element consists of a tag name, attributes, and child nodes (including text nodes and other elements).">Element</a></code> could throw a <code>StackOverflowError</code> due to excessive recursion. Namely: <code>#data()</code>, <code>#hasText()</code>, <code>#parents()</code>, and <code>#wrap(html)</code>. <a href="https://github.com/jhy/jsoup/issues/1864">#1864</a></li> </ul> <h2>Changes</h2> <ul> <li>Deprecated the unused <code><a href="https://jsoup.org/apidocs/org/jsoup/nodes/Document.html#normalise()" title="Deprecated. as normalization occurs during the HTML parse, this method is no longer useful and will be retired in the next release.">Document.normalise()</a></code> method. Normalization occurs during the HTML tree construction, and no longer as a distinct phase.</li> </ul> <p></p> <hr> <p></p> <p>My sincere thanks to everyone who contributed patches, suggestions, and bug reports. If you have any suggestions for the next release, I would love to hear them; please get in touch with me <a href="https://jhy.io/">directly</a>.</p> <p>You can also <a rel="me" href="https://tilde.zone/@jhy">follow me</a> (<b><a rel="me" href="https://tilde.zone/@jhy">@jhy@tilde.zone</a></b>) on Mastodon / Fediverse to receive occasional notes about jsoup releases.</p>
jsoup 1.15.3 is out now, and includes a security fix for potential XSS attacks, along with other bug fixes and improvements, including more descriptiv…
jsoup 1.15.3 is out now, and includes a security fix for potential XSS attacks, along with other bug fixes and improvements, including more descriptive validation error messages.
Details:
Aug 24, 2022
jsoup 1.15.3 is out now, and includes a security fix for potential XSS attacks, along with other improvements including more descriptive validation error messages. jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of HTML5 DOM methods and CSS selectors. Download jsoup now.
jsoup 1.15.2 is out now with a bunch of improvements and bug fixes.
jsoup 1.15.2 is out now with a bunch of improvements and bug fixes.
jsoup 1.15.1 is out now with a bunch of improvements and bug fixes.
jsoup 1.15.1 is out now with a bunch of improvements and bug fixes.
jsoup 1.14.3 is out now, adding native XPath selector support, improved support, and also includes a bunch of bug fixes, improvements, and performance
jsoup 1.14.3 is out now, adding native XPath selector support, improved <template> support, and also includes a bunch of bug fixes, improvements, and performance enhancements.
See the release announcement for the full changelog.
Caught by the fuzz! jsoup 1.14.2 is out now, and includes a set of parser bug fixes and improvements for handling rough HTML and XML, as identified by
Caught by the fuzz! jsoup 1.14.2 is out now, and includes a set of parser bug fixes and improvements for handling rough HTML and XML, as identified by the Jazzer JVM fuzzer. This release also includes other fixes and improvements.
See the release announcement for the full changelog.
jsoup 1.14.1 is out now, with simple request session management, increased parse robustness, and a ton of other improvements, speed-ups, and bug fixes
jsoup 1.14.1 is out now, with simple request session management, increased parse robustness, and a ton of other improvements, speed-ups, and bug fixes.
See the full announcement for all the details on what's changed.
` <!-- jsoup HTML parser library @ https://jsoup.org/ --> org.jsoup jsoup 1.13.1 `
jsoup 1.13.1
See the release notes.
<dependency>
<!-- jsoup HTML parser library @ https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.