This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new aa41699e6f [docs] Escape ampersand (&) in config doc generator's 
escapeCharacters (#8552)
aa41699e6f is described below

commit aa41699e6f32299a62a976fde746e7919347fbfc
Author: Eunbin Son <[email protected]>
AuthorDate: Mon Jul 13 11:22:32 2026 +0900

    [docs] Escape ampersand (&) in config doc generator's escapeCharacters 
(#8552)
---
 .../java/org/apache/paimon/docs/util/Utils.java    |  1 +
 .../org/apache/paimon/docs/util/UtilsTest.java     | 49 ++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/paimon-docs/src/main/java/org/apache/paimon/docs/util/Utils.java 
b/paimon-docs/src/main/java/org/apache/paimon/docs/util/Utils.java
index 9d0e4e82f3..1f85f175c9 100644
--- a/paimon-docs/src/main/java/org/apache/paimon/docs/util/Utils.java
+++ b/paimon-docs/src/main/java/org/apache/paimon/docs/util/Utils.java
@@ -29,6 +29,7 @@ public class Utils {
 
     public static String escapeCharacters(String value) {
         return value.replaceAll("<wbr>", TEMPORARY_PLACEHOLDER)
+                .replaceAll("&", "&amp;")
                 .replaceAll("<", "&lt;")
                 .replaceAll(">", "&gt;")
                 .replaceAll(TEMPORARY_PLACEHOLDER, "<wbr>");
diff --git 
a/paimon-docs/src/test/java/org/apache/paimon/docs/util/UtilsTest.java 
b/paimon-docs/src/test/java/org/apache/paimon/docs/util/UtilsTest.java
new file mode 100644
index 0000000000..2f25787db1
--- /dev/null
+++ b/paimon-docs/src/test/java/org/apache/paimon/docs/util/UtilsTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.docs.util;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link Utils}. */
+class UtilsTest {
+
+    @Test
+    void testEscapeAmpersand() {
+        assertThat(Utils.escapeCharacters("a&b")).isEqualTo("a&amp;b");
+    }
+
+    @Test
+    void testAmpersandEscapedBeforeAngleBrackets() {
+        // '&' must be replaced first so the '&' produced by the '<'/'>' 
escaping is not
+        // double-escaped into "&amp;lt;"/"&amp;gt;".
+        
assertThat(Utils.escapeCharacters("<a&b>")).isEqualTo("&lt;a&amp;b&gt;");
+    }
+
+    @Test
+    void testWbrPreservedWhileAmpersandEscaped() {
+        
assertThat(Utils.escapeCharacters("x&<wbr>y")).isEqualTo("x&amp;<wbr>y");
+    }
+
+    @Test
+    void testAngleBracketsStillEscaped() {
+        assertThat(Utils.escapeCharacters("<a>")).isEqualTo("&lt;a&gt;");
+    }
+}

Reply via email to