You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kw...@apache.org on 2023/10/08 15:12:44 UTC

[maven-doxia] branch feature/add-test-for-url-encoding-of-link updated (608ebb1b -> 88549533)

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

kwin pushed a change to branch feature/add-test-for-url-encoding-of-link
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git


 discard 608ebb1b Add test for preserving (and not adding additional) URL encoding
     new 88549533 Add test for preserving (and not adding additional) URL encoding

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (608ebb1b)
            \
             N -- N -- N   refs/heads/feature/add-test-for-url-encoding-of-link (88549533)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 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:
 .../test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)


[maven-doxia] 01/01: Add test for preserving (and not adding additional) URL encoding

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

kwin pushed a commit to branch feature/add-test-for-url-encoding-of-link
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 885495339152b73e9c73fd91b612917ec9c6eb0d
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Oct 8 17:10:55 2023 +0200

    Add test for preserving (and not adding additional) URL encoding
    
    Make Sink.link(...) javadoc more HTML agnostic by just referencing the
    URI RFC
---
 .../maven/doxia/parser/Xhtml5BaseParserTest.java    | 21 ++++++++++++++++++++-
 .../main/java/org/apache/maven/doxia/sink/Sink.java |  7 +++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java
index 458d2f47..5e9e1707 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/parser/Xhtml5BaseParserTest.java
@@ -695,6 +695,26 @@ public class Xhtml5BaseParserTest extends AbstractParserTest {
         assertEquals("figure_", it.next().getName());
     }
 
+    @Test
+    public void testLink() throws Exception {
+        // param1 value = "/&ΓΌ" URL encoded twice!
+        String text = "<div><a href=\"http://www.fo.com/index.html&amp;param1=%252F%2526%25C3%25BC\"></a></div>";
+
+        parser.parse(text, sink);
+        Iterator<SinkEventElement> it = sink.getEventList().iterator();
+
+        SinkEventElement element = it.next();
+        assertEquals("division", element.getName());
+
+        element = it.next();
+        assertEquals("link", element.getName());
+        assertEquals("http://www.fo.com/index.html&param1=%252F%2526%25C3%25BC", element.getArgs()[0]);
+        assertEquals("link_", it.next().getName());
+
+        element = it.next();
+        assertEquals("division_", element.getName());
+    }
+
     @Test
     public void testAnchorLink() throws Exception {
         String text = "<div><a href=\"\"></a>" + "<a href=\"valid\"></a>"
@@ -748,7 +768,6 @@ public class Xhtml5BaseParserTest extends AbstractParserTest {
         element = it.next();
         assertEquals("division_", element.getName());
     }
-
     /**
      * Test entities in attributes.
      *
diff --git a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
index c89ad68e..ecabcbee 100644
--- a/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
+++ b/doxia-sink-api/src/main/java/org/apache/maven/doxia/sink/Sink.java
@@ -1433,9 +1433,11 @@ public interface Sink extends AutoCloseable {
      * Starts a link.
      *
      * <p>
-     *   The <code>name</code> parameter has to be a valid html <code>href</code>
-     *   parameter, ie for internal links (links to an anchor within the same source
+     *   The <code>name</code> parameter has to be a valid URI according to
+     *   <a href="https://datatracker.ietf.org/doc/html/rfc3986">RFC 3986</a>,
+     *   i.e. for internal links (links to an anchor within the same source
      *   document), <code>name</code> should start with the character "#".
+     *   This also implies that all unsafe characters are already encoded.
      * </p>
      * <p>
      *   Supported attributes are the {@link SinkEventAttributes base attributes} plus:
@@ -1455,6 +1457,7 @@ public interface Sink extends AutoCloseable {
      * @param name the name of the link.
      * @param attributes A set of {@link SinkEventAttributes}, may be <code>null</code>.
      * @since 1.1
+     * @see java.net.URI#toASCIIString()
      */
     void link(String name, SinkEventAttributes attributes);