Repository: jhy/jsoup
Pull request #1996 (2023-09-11 23:44:17)

Bump jetty.version from 9.4.51.v20230217 to 9.4.52.v20230823
Bumps `jetty.version` from 9.4.51.v20230217 to 9.4.52.v20230823.
Updates `org.eclipse.jetty:jetty-server` from 9.4.51.v20230217 to 9.4.52.v20230823
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/eclipse/jetty.project/releases">org.eclipse.jetty:jetty-server's releases</a>.</em></p>
<blockquote>
<h2>9.4.52.v20230823</h2>
<h1>Sponsored Release</h1>
<p>This is a release of the <a href="https://redirect.github.com/eclipse/jetty.project/issues/7958">End of Community Support Jetty 9.x series</a> that was sponsored by a <a href="https://github.com/eclipse/jetty.project/blob/HEAD/mailto:sales@webtide.com">support contract from Webtide.com</a></p>
<h1>Security Updates</h1>
<ul>
<li>This release provides a workaround for Security Advisory GHSA-58qw-p7qm-5rvh</li>
</ul>
<h1>Special Thanks to the following Eclipse Jetty community members</h1>
<ul>
<li><a href="https://github.com/RangerRick"><code>@​RangerRick</code></a> (Benjamin Reed)</li>
</ul>
<h1>Changelog</h1>
<ul>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10352">#10352</a> - Backport of various cleanups in <code>HttpParser</code> from <code>jetty-10.0.x</code></li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10337">#10337</a> - <code>SizeLimitHandler</code> does not enforce 0 responseLimit</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10169">#10169</a> - make sure that a ServiceLoader is retrieved before iterating (<a href="https://github.com/RangerRick"><code>@​RangerRick</code></a>)</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10066">#10066</a> - Allow <code>SAXParserFactory</code> or <code>SAXParser</code> to be configured in Jetty's <code>XmlParser</code> class  - Allows for GHSA-58qw-p7qm-5rvh workaround</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9887">#9887</a> - Deprecate <code>CGI</code> Servlet</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9716">#9716</a> - Deprecate <code>PushSessionCacheFilter</code></li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9660">#9660</a> - Bring back some openid improvements from <code>jetty-10.0.x</code></li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9476">#9476</a> - onCompleteFailure called multiple times</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/eclipse/jetty.project/commit/abdcda73818a1a2c705da276edb0bf6581e7997e"><code>abdcda7</code></a> Updating to version 9.4.52.v20230823</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/d90c600328309d72817e60a78acb1f4239c64f16"><code>d90c600</code></a> Improve release-jetty.sh script</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/eb390555ff218fee5e39e48eaa8df0a4dbd777a2"><code>eb39055</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10344">#10344</a> from eclipse/jetty-9.4.x-fixSizeLimitHandler</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/e4d596eafc887bcd813ae6e28295b5ce327def47"><code>e4d596e</code></a> Backport of various cleanups in <code>HttpParser</code> from <code>jetty-10.0.x</code> (<a href="https://redirect.github.com/eclipse/jetty.project/issues/10352">#10352</a>)</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/325d83912d5516a6869dcfeb4293cfee97371b39"><code>325d839</code></a> update test expectations in SizeLimitHandlerTest</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/0c4f879a3a30bc92ecda232f31f075ce6aa3bd01"><code>0c4f879</code></a> Issue <a href="https://redirect.github.com/eclipse/jetty.project/issues/10337">#10337</a> - fixes to SizeLimitHandler</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/d4d8832b11f02bd334b42af07f598ce904bf7736"><code>d4d8832</code></a> Issue <a href="https://redirect.github.com/eclipse/jetty.project/issues/10066">#10066</a> - Allow customization of <code>SAXParserFactory</code> and <code>SAXParser</code> in `...</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/490626e6a572822943debc43611b701c144c5f44"><code>490626e</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10169">#10169</a> from RangerRick/ranger/jetty-npe-websocket-init</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/88d70ca6953a3010a63205536e4477be5a8fac3e"><code>88d70ca</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10261">#10261</a> from eclipse/dependabot/maven/jetty-9.4.x/org.jboss...</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/ee09f12e78d025f4d02e565a2c3ad4b53849d255"><code>ee09f12</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10254">#10254</a> from eclipse/dependabot/maven/jetty-9.4.x/jmh.versi...</li>
<li>Additional commits viewable in <a href="https://github.com/eclipse/jetty.project/compare/jetty-9.4.51.v20230217...jetty-9.4.52.v20230823">compare view</a></li>
</ul>
</details>
<br />

Updates `org.eclipse.jetty:jetty-servlet` from 9.4.51.v20230217 to 9.4.52.v20230823
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/eclipse/jetty.project/releases">org.eclipse.jetty:jetty-servlet's releases</a>.</em></p>
<blockquote>
<h2>9.4.52.v20230823</h2>
<h1>Sponsored Release</h1>
<p>This is a release of the <a href="https://redirect.github.com/eclipse/jetty.project/issues/7958">End of Community Support Jetty 9.x series</a> that was sponsored by a <a href="https://github.com/eclipse/jetty.project/blob/HEAD/mailto:sales@webtide.com">support contract from Webtide.com</a></p>
<h1>Security Updates</h1>
<ul>
<li>This release provides a workaround for Security Advisory GHSA-58qw-p7qm-5rvh</li>
</ul>
<h1>Special Thanks to the following Eclipse Jetty community members</h1>
<ul>
<li><a href="https://github.com/RangerRick"><code>@​RangerRick</code></a> (Benjamin Reed)</li>
</ul>
<h1>Changelog</h1>
<ul>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10352">#10352</a> - Backport of various cleanups in <code>HttpParser</code> from <code>jetty-10.0.x</code></li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10337">#10337</a> - <code>SizeLimitHandler</code> does not enforce 0 responseLimit</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10169">#10169</a> - make sure that a ServiceLoader is retrieved before iterating (<a href="https://github.com/RangerRick"><code>@​RangerRick</code></a>)</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/10066">#10066</a> - Allow <code>SAXParserFactory</code> or <code>SAXParser</code> to be configured in Jetty's <code>XmlParser</code> class  - Allows for GHSA-58qw-p7qm-5rvh workaround</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9887">#9887</a> - Deprecate <code>CGI</code> Servlet</li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9716">#9716</a> - Deprecate <code>PushSessionCacheFilter</code></li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9660">#9660</a> - Bring back some openid improvements from <code>jetty-10.0.x</code></li>
<li><a href="https://redirect.github.com/eclipse/jetty.project/issues/9476">#9476</a> - onCompleteFailure called multiple times</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/eclipse/jetty.project/commit/abdcda73818a1a2c705da276edb0bf6581e7997e"><code>abdcda7</code></a> Updating to version 9.4.52.v20230823</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/d90c600328309d72817e60a78acb1f4239c64f16"><code>d90c600</code></a> Improve release-jetty.sh script</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/eb390555ff218fee5e39e48eaa8df0a4dbd777a2"><code>eb39055</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10344">#10344</a> from eclipse/jetty-9.4.x-fixSizeLimitHandler</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/e4d596eafc887bcd813ae6e28295b5ce327def47"><code>e4d596e</code></a> Backport of various cleanups in <code>HttpParser</code> from <code>jetty-10.0.x</code> (<a href="https://redirect.github.com/eclipse/jetty.project/issues/10352">#10352</a>)</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/325d83912d5516a6869dcfeb4293cfee97371b39"><code>325d839</code></a> update test expectations in SizeLimitHandlerTest</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/0c4f879a3a30bc92ecda232f31f075ce6aa3bd01"><code>0c4f879</code></a> Issue <a href="https://redirect.github.com/eclipse/jetty.project/issues/10337">#10337</a> - fixes to SizeLimitHandler</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/d4d8832b11f02bd334b42af07f598ce904bf7736"><code>d4d8832</code></a> Issue <a href="https://redirect.github.com/eclipse/jetty.project/issues/10066">#10066</a> - Allow customization of <code>SAXParserFactory</code> and <code>SAXParser</code> in `...</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/490626e6a572822943debc43611b701c144c5f44"><code>490626e</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10169">#10169</a> from RangerRick/ranger/jetty-npe-websocket-init</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/88d70ca6953a3010a63205536e4477be5a8fac3e"><code>88d70ca</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10261">#10261</a> from eclipse/dependabot/maven/jetty-9.4.x/org.jboss...</li>
<li><a href="https://github.com/eclipse/jetty.project/commit/ee09f12e78d025f4d02e565a2c3ad4b53849d255"><code>ee09f12</code></a> Merge pull request <a href="https://redirect.github.com/eclipse/jetty.project/issues/10254">#10254</a> from eclipse/dependabot/maven/jetty-9.4.x/jmh.versi...</li>
<li>Additional commits viewable in <a href="https://github.com/eclipse/jetty.project/compare/jetty-9.4.51.v20230217...jetty-9.4.52.v20230823">compare view</a></li>
</ul>
</details>
<br />

<details>
<summary>Most Recent Ignore Conditions Applied to This Pull Request</summary>

| Dependency Name | Ignore Conditions |
| --- | --- |
| org.eclipse.jetty:jetty-servlet | [> 9.4.42.v20210604] |
</details>


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)

---

**Note:** Dependabot was ignoring updates to this dependency, but since you've updated it yourself we've started tracking it for you again. 🤖

<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 b/CHANGES
index f8c1966d..989650e8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -31,6 +31,9 @@ Release 1.16.2 [PENDING]
   * Bugfix: `form` elements and empty elements (such as `img`) did not have their attributes de-duplicated.
     <https://github.com/jhy/jsoup/pull/1950>
 
+  * Bugfix: if Document.OutputSettings was cloned from a clone, an NPE would be thrown when used.
+    <https://github.com/jhy/jsoup/pull/1964>
+
   * Bugfix: in Jsoup.connect(url), 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.
diff --git a/pom.xml b/pom.xml
index 110c3375..f01b7553 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,7 @@
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <jetty.version>9.4.51.v20230217</jetty.version>
+    <jetty.version>9.4.52.v20230823</jetty.version>
   </properties>
 
   <build>
@@ -172,12 +172,12 @@
       </plugin>
       <plugin>
         <artifactId>maven-release-plugin</artifactId>
-        <version>3.0.0</version>
+        <version>3.0.1</version>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>3.1.0</version>
+        <version>3.1.2</version>
         <configuration>
           <!-- smaller stack to find stack overflows -->
           <argLine>-Xss256k</argLine>
@@ -203,7 +203,7 @@
         <!-- API version compat check - https://siom79.github.io/japicmp/ -->
         <groupId>com.github.siom79.japicmp</groupId>
         <artifactId>japicmp-maven-plugin</artifactId>
-        <version>0.17.2</version>
+        <version>0.17.3</version>
         <configuration>
           <!-- hard code previous version; can't detect when running stateless on build server -->
           <oldVersion>
@@ -328,7 +328,7 @@
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter</artifactId>
-      <version>5.9.3</version>
+      <version>5.10.0</version>
       <scope>test</scope>
     </dependency>
 
diff --git a/src/main/java/org/jsoup/nodes/Document.java b/src/main/java/org/jsoup/nodes/Document.java
index 70c571f8..9930dc5e 100644
--- a/src/main/java/org/jsoup/nodes/Document.java
+++ b/src/main/java/org/jsoup/nodes/Document.java
@@ -385,9 +385,9 @@ public class Document extends Element {
         public enum Syntax {html, xml}
 
         private Entities.EscapeMode escapeMode = Entities.EscapeMode.base;
-        private Charset charset = DataUtil.UTF_8;
+        private Charset charset;
+        Entities.CoreCharset coreCharset; // fast encoders for ascii and utf8
         private final ThreadLocal<CharsetEncoder> encoderThreadLocal = new ThreadLocal<>(); // initialized by start of OuterHtmlVisitor
-        @Nullable Entities.CoreCharset coreCharset; // fast encoders for ascii and utf8
 
         private boolean prettyPrint = true;
         private boolean outline = false;
@@ -395,7 +395,9 @@ public class Document extends Element {
         private int maxPaddingWidth = 30;
         private Syntax syntax = Syntax.html;
 
-        public OutputSettings() {}
+        public OutputSettings() {
+            charset(DataUtil.UTF_8);
+        }
         
         /**
          * Get the document's current HTML escape mode: <code>base</code>, which provides a limited set of named HTML
@@ -439,6 +441,7 @@ public class Document extends Element {
          */
         public OutputSettings charset(Charset charset) {
             this.charset = charset;
+            coreCharset = Entities.CoreCharset.byName(charset.name());
             return this;
         }
 
@@ -456,7 +459,6 @@ public class Document extends Element {
             // created at start of OuterHtmlVisitor so each pass has own encoder, so OutputSettings can be shared among threads
             CharsetEncoder encoder = charset.newEncoder();
             encoderThreadLocal.set(encoder);
-            coreCharset = Entities.CoreCharset.byName(encoder.charset().name());
             return encoder;
         }
 
@@ -570,7 +572,7 @@ public class Document extends Element {
             } catch (CloneNotSupportedException e) {
                 throw new RuntimeException(e);
             }
-            clone.charset(charset.name()); // new charset and charset encoder
+            clone.charset(charset.name()); // new charset, coreCharset, and charset encoder
             clone.escapeMode = Entities.EscapeMode.valueOf(escapeMode.name());
             // indentAmount, maxPaddingWidth, and prettyPrint are primitives so object.clone() will handle
             return clone;


Test patch:
diff --git a/src/test/java/org/jsoup/nodes/EntitiesTest.java b/src/test/java/org/jsoup/nodes/EntitiesTest.java
index 886dfca5..7243c2f5 100644
--- a/src/test/java/org/jsoup/nodes/EntitiesTest.java
+++ b/src/test/java/org/jsoup/nodes/EntitiesTest.java
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.jsoup.nodes.Document.OutputSettings;
 import static org.jsoup.nodes.Entities.EscapeMode.*;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class EntitiesTest {
@@ -163,4 +164,15 @@ public class EntitiesTest {
         Document xml = Jsoup.parse(input, "", Parser.xmlParser());
         assertEquals(input, xml.html());
     }
+    
+    @Test public void escapeByClonedOutputSettings() {
+        OutputSettings outputSettings = new OutputSettings();
+        String text = "Hello &<> Å å π 新 there ¾ © »";
+        OutputSettings clone1 = outputSettings.clone();
+        OutputSettings clone2 = outputSettings.clone();
+
+        String escaped1 = assertDoesNotThrow(() -> Entities.escape(text, clone1));
+        String escaped2 = assertDoesNotThrow(() -> Entities.escape(text, clone2));
+        assertEquals(escaped1, escaped2);
+    }
 }