Repository: jhy/jsoup
Pull request #2243 (2024-12-09 23:04:51)

Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.1 to 3.11.2
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.11.1 to 3.11.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/apache/maven-javadoc-plugin/releases">org.apache.maven.plugins:maven-javadoc-plugin's releases</a>.</em></p>
<blockquote>
<h2>3.11.2</h2>
<h2>🚀 New features and improvements</h2>
<ul>
<li><a href="https://issues.apache.org/jira/browse/MJAVADOC-823">[MJAVADOC-823]</a> - legacyMode keeps using module-info.java (-sourcedirectory still use as well as java files input) (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/343">#343</a>) <a href="https://github.com/olamy"><code>@​olamy</code></a></li>
<li><a href="https://issues.apache.org/jira/browse/MJAVADOC-814">[MJAVADOC-814]</a> - handle parameters such packages with multi lines (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/337">#337</a>) <a href="https://github.com/olamy"><code>@​olamy</code></a></li>
<li><a href="https://issues.apache.org/jira/browse/MJAVADOC-822">[MJAVADOC-822]</a> - skippedModules should be more scalable and support regex (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/336">#336</a>) <a href="https://github.com/olamy"><code>@​olamy</code></a></li>
</ul>
<h2>📦 Dependency updates</h2>
<ul>
<li>Bump com.thoughtworks.qdox:qdox from 2.1.0 to 2.2.0 (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/344">#344</a>) <a href="https://github.com/dependabot"><code>@​dependabot</code></a></li>
<li>Bump commons-io:commons-io from 2.17.0 to 2.18.0 (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/342">#342</a>) <a href="https://github.com/dependabot"><code>@​dependabot</code></a></li>
<li>Bump org.codehaus.mojo:l10n-maven-plugin from 1.0.0 to 1.1.0 (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/335">#335</a>) <a href="https://github.com/dependabot"><code>@​dependabot</code></a></li>
</ul>
<h2>👻 Maintenance</h2>
<ul>
<li>refactor: Replace Plexus AbstractLogEnabled with SLF4J (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/pull/338">#338</a>) <a href="https://github.com/timtebeek"><code>@​timtebeek</code></a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/44cbab77e246336cf625967a8076917f732d4e2f"><code>44cbab7</code></a> [maven-release-plugin] prepare release maven-javadoc-plugin-3.11.2</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/3de45d8e3103e616fafac71ed30ccea83fbf7daa"><code>3de45d8</code></a> use github for scm</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/45ccf06c375d97229c5a12d7cbae1c6de7ddd36b"><code>45ccf06</code></a> Bump com.thoughtworks.qdox:qdox from 2.1.0 to 2.2.0</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/530fa0128f1745573067551630468e8d42459644"><code>530fa01</code></a> [MJAVADOC-823] legacyMode keeps using module-info.java (-sourcedirectory stil...</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/3a16d92e01e827158d82a521cad366a8ba005d79"><code>3a16d92</code></a> Bump commons-io:commons-io from 2.17.0 to 2.18.0</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/69c1ba77eafbccba24c0926e7283a12fdd0706cc"><code>69c1ba7</code></a> Migrate from Plexus to Sisu Guice (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/issues/341">#341</a>)</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/39857ea3be42b8f9fde826b4456d49d2da91f2fc"><code>39857ea</code></a> Remove usages of deprecated ReaderFactory class (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/issues/339">#339</a>)</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/314203a01e146a78ef8a2564034944d8c1b62b88"><code>314203a</code></a> [MJAVADOC-814] handle parameters such packages with multi lines (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/issues/337">#337</a>)</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/3bb982d1fc30d0e6748d400b176eec7cb4be1018"><code>3bb982d</code></a> refactor: Replace Plexus AbstractLogEnabled with SLF4J (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/issues/338">#338</a>)</li>
<li><a href="https://github.com/apache/maven-javadoc-plugin/commit/76826c865a684c2bac489baad3bc3ccf28dc66e5"><code>76826c8</code></a> [MJAVADOC-822] skippedModules should be more scalable and support regex (<a href="https://redirect.github.com/apache/maven-javadoc-plugin/issues/336">#336</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.11.1...maven-javadoc-plugin-3.11.2">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=org.apache.maven.plugins:maven-javadoc-plugin&package-manager=maven&previous-version=3.11.1&new-version=3.11.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

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-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will 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 version` will 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 dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/CHANGES.md b/CHANGES.md
index 2d7c9e28..b0e9da45 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -15,6 +15,9 @@
 
 * When serializing to XML, attribute names containing `-`, `.`, or digits were incorrectly marked as invalid and
   removed. [2235](https://github.com/jhy/jsoup/issues/2235) 
+* If an element has an `;` in an attribute name, it could not be converted to a W3C DOM element, and so subsquent XPath
+  queries could miss that element. Now, the attribute name is more completely
+  normalized. [2244](https://github.com/jhy/jsoup/issues/2244)
 
 ## 1.18.2 (2024-Nov-27)
 
diff --git a/pom.xml b/pom.xml
index 5ff9aeaf..ac4a6b88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,7 +119,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
-        <version>3.11.1</version>
+        <version>3.11.2</version>
         <configuration>
           <doclint>none</doclint>
           <source>8</source>
diff --git a/src/main/java/org/jsoup/helper/W3CDom.java b/src/main/java/org/jsoup/helper/W3CDom.java
index 3946366e..3a8a64f1 100644
--- a/src/main/java/org/jsoup/helper/W3CDom.java
+++ b/src/main/java/org/jsoup/helper/W3CDom.java
@@ -425,9 +425,17 @@ public class W3CDom {
 
         private void copyAttributes(org.jsoup.nodes.Node source, Element el) {
             for (Attribute attribute : source.attributes()) {
-                String key = Attribute.getValidKey(attribute.getKey(), syntax);
-                if (key != null) { // null if couldn't be coerced to validity
-                    el.setAttribute(key, attribute.getValue());
+                // the W3C DOM has a different allowed set of characters than HTML5 (that Attribute.getValidKey return, partic does not allow ';'). So if we except when using HTML, go to more restricted XML
+                try {
+                    String key = Attribute.getValidKey(attribute.getKey(), syntax);
+                    if (key != null) // null if couldn't be coerced to validity
+                        el.setAttribute(key, attribute.getValue());
+                } catch (DOMException e) {
+                    if (syntax != Syntax.xml) {
+                        String key = Attribute.getValidKey(attribute.getKey(), Syntax.xml);
+                        if (key != null)
+                            el.setAttribute(key, attribute.getValue()); // otherwise, will skip attribute
+                    }
                 }
             }
         }


Test patch:
diff --git a/src/test/java/org/jsoup/select/XpathTest.java b/src/test/java/org/jsoup/select/XpathTest.java
index ae278322..b9aa1cf7 100644
--- a/src/test/java/org/jsoup/select/XpathTest.java
+++ b/src/test/java/org/jsoup/select/XpathTest.java
@@ -236,6 +236,14 @@ public class XpathTest {
         assertEquals("1568491379", isbn.first().text());
     }
 
+    @Test void withSemiInAttributeName() {
+        // https://github.com/jhy/jsoup/issues/2244
+        String html = "<div grading?&quot;=foo>One</div>";
+        Document doc = Jsoup.parse(html);
+        Elements els = doc.selectXpath("//div");
+        assertEquals(1, els.size());
+    }
+
     // minimal, no-op implementation class to verify users can load a factory to support XPath 2.0 etc
     public static class AlternateXpathFactory extends XPathFactory {
         public AlternateXpathFactory() {