You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dj...@apache.org on 2022/01/05 19:00:02 UTC

[camel] branch main updated (bfecd55 -> f132a2f)

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

djencks pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from bfecd55  CAMEL-17345: camel-jbang create maven project (#6583)
     new 8d48dde  CAMEL-17433 fix JavadocHelper
     new f132a2f  CAMEL-17433 undo previous workaround

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../salesforce/SalesforceEndpointConfig.java       |  8 ++---
 .../apache/camel/tooling/util/JavadocHelper.java   |  9 +++---
 .../camel/tooling/util/JavadocHelperTest.java      | 36 ++++++++++++++++++++++
 3 files changed, 45 insertions(+), 8 deletions(-)

[camel] 01/02: CAMEL-17433 fix JavadocHelper

Posted by dj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

djencks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8d48dde56f525b3cec9e7d42741994a43ce8995e
Author: David Jencks <dj...@apache.org>
AuthorDate: Tue Jan 4 14:45:32 2022 -0800

    CAMEL-17433 fix JavadocHelper
---
 .../apache/camel/tooling/util/JavadocHelper.java   |  9 +++---
 .../camel/tooling/util/JavadocHelperTest.java      | 36 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/tooling/camel-tooling-util/src/main/java/org/apache/camel/tooling/util/JavadocHelper.java b/tooling/camel-tooling-util/src/main/java/org/apache/camel/tooling/util/JavadocHelper.java
index 9a89dcf..e940559 100644
--- a/tooling/camel-tooling-util/src/main/java/org/apache/camel/tooling/util/JavadocHelper.java
+++ b/tooling/camel-tooling-util/src/main/java/org/apache/camel/tooling/util/JavadocHelper.java
@@ -20,7 +20,7 @@ import static org.apache.camel.tooling.util.Strings.isNullOrEmpty;
 
 public final class JavadocHelper {
 
-    private static final String VALID_CHARS = ".,-='/\\!&%():;#${}";
+    private static final String VALID_CHARS = ".,-='/\\!&%():;#${}<>";
 
     private JavadocHelper() {
     }
@@ -87,8 +87,9 @@ public final class JavadocHelper {
         }
 
         String s = sb.toString();
-        // remove all XML tags
-        s = s.replaceAll("<.*?>", "");
+        // remove all XML tags. This isn't complete but likely to find anything actually used.
+        s = s.replaceAll("<(\\w|:|_)(\\w|:|_|-|\\.|\\d)*\\s.*/?>", "");
+        s = s.replaceAll("</(\\w|:|_)(\\w|:|_|-|\\.|\\d)*\\s*>", "");
         // remove {@link inlined javadoc links which is special handled
         s = s.replaceAll("\\{@link\\s\\w+\\s(\\w+)}", "$1");
         s = s.replaceAll("\\{@link\\s([\\w]+)}", "$1");
@@ -130,7 +131,7 @@ public final class JavadocHelper {
             return "";
         }
         // must replace amp first, so we dont replace &lt; to amp later
-        text = text.replace("&", "&amp;");
+        text = text.replaceAll("&(?!(amp;)|(lt;)|(gt;)|(quot;))", "&amp;");
         text = text.replace("\"", "&quot;");
         text = text.replace("<", "&lt;");
         text = text.replace(">", "&gt;");
diff --git a/tooling/camel-tooling-util/src/test/java/org/apache/camel/tooling/util/JavadocHelperTest.java b/tooling/camel-tooling-util/src/test/java/org/apache/camel/tooling/util/JavadocHelperTest.java
index 6e1698f..05dbfca 100644
--- a/tooling/camel-tooling-util/src/test/java/org/apache/camel/tooling/util/JavadocHelperTest.java
+++ b/tooling/camel-tooling-util/src/test/java/org/apache/camel/tooling/util/JavadocHelperTest.java
@@ -99,4 +99,40 @@ public class JavadocHelperTest {
         Assertions.assertEquals("Provides methods to interact with Transactions. E.g. sales, credits, refunds, searches, etc.",
                 s3);
     }
+
+    @Test
+    public void testltgtInJavaDoc() throws Exception {
+        String s = " * valid for versions < 26.0.";
+        String s2 = JavadocHelper.sanitizeDescription(s, false);
+        Assertions.assertEquals(s.substring(3), s2);
+        String s3 = " * valid for versions >= 26.0.";
+        String s4 = JavadocHelper.sanitizeDescription(s3, false);
+        Assertions.assertEquals(s3.substring(3), s4);
+    }
+
+    @Test
+    public void testRemoveXmlTagsInJavaDoc() throws Exception {
+        String s = " * foo <xs:foo a=\"x\" b=\"y\"> bar";
+        String s2 = JavadocHelper.sanitizeDescription(s, false);
+        Assertions.assertEquals("foo bar", s2);
+        String s3 = " * foo </xs:foo> bar";
+        String s4 = JavadocHelper.sanitizeDescription(s3, false);
+        Assertions.assertEquals("foo bar", s4);
+        String s5 = " * foo </xs:foo > bar";
+        String s6 = JavadocHelper.sanitizeDescription(s5, false);
+        Assertions.assertEquals("foo bar", s6);
+        String s7 = " * this < is not an xml > tag";
+        String s8 = JavadocHelper.sanitizeDescription(s7, false);
+        Assertions.assertEquals(s7.substring(3), s8);
+    }
+
+    @Test
+    public void testXmlEncode() throws Exception {
+        String s = "foo &amp; bar &gt; baz &lt; foo &quot; bar";
+        String s2 = JavadocHelper.xmlEncode(s);
+        Assertions.assertEquals(s, s2);
+        String s3 = "foo & bar > baz < foo \" bar";
+        String s4 = JavadocHelper.xmlEncode(s3);
+        Assertions.assertEquals(s, s4);
+    }
 }

[camel] 02/02: CAMEL-17433 undo previous workaround

Posted by dj...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

djencks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f132a2f9ff6e09005f17d588207d97a7a7373caf
Author: David Jencks <dj...@apache.org>
AuthorDate: Tue Jan 4 14:58:10 2022 -0800

    CAMEL-17433 undo previous workaround
---
 .../camel/component/salesforce/SalesforceEndpointConfig.java      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
index 70ba1bc..75a404b 100644
--- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
+++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/SalesforceEndpointConfig.java
@@ -630,7 +630,7 @@ public class SalesforceEndpointConfig implements Cloneable {
     }
 
     /**
-     * Notify for create operation, defaults to false (API version &gt;= 29.0)
+     * Notify for create operation, defaults to false (API version >= 29.0)
      */
     public void setNotifyForOperationCreate(Boolean notifyForOperationCreate) {
         this.notifyForOperationCreate = notifyForOperationCreate;
@@ -641,7 +641,7 @@ public class SalesforceEndpointConfig implements Cloneable {
     }
 
     /**
-     * Notify for update operation, defaults to false (API version &gt;= 29.0)
+     * Notify for update operation, defaults to false (API version >= 29.0)
      */
     public void setNotifyForOperationUpdate(Boolean notifyForOperationUpdate) {
         this.notifyForOperationUpdate = notifyForOperationUpdate;
@@ -652,7 +652,7 @@ public class SalesforceEndpointConfig implements Cloneable {
     }
 
     /**
-     * Notify for delete operation, defaults to false (API version &gt;= 29.0)
+     * Notify for delete operation, defaults to false (API version >= 29.0)
      */
     public void setNotifyForOperationDelete(Boolean notifyForOperationDelete) {
         this.notifyForOperationDelete = notifyForOperationDelete;
@@ -663,7 +663,7 @@ public class SalesforceEndpointConfig implements Cloneable {
     }
 
     /**
-     * Notify for un-delete operation, defaults to false (API version &gt;= 29.0)
+     * Notify for un-delete operation, defaults to false (API version >= 29.0)
      */
     public void setNotifyForOperationUndelete(Boolean notifyForOperationUndelete) {
         this.notifyForOperationUndelete = notifyForOperationUndelete;