Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248001

javadoc generates invalid HTML pages whose ftp:// links are broken

    XMLWordPrintable

Details

    • b18
    • x86_64
    • windows_10

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        OS: Generic
        java -version:
          openjdk version "15-ea" 2020-09-15
          OpenJDK Runtime Environment (build 15-ea+27-1372)
          OpenJDK 64-Bit Server VM (build 15-ea+27-1372, mixed mode, sharing)

        A DESCRIPTION OF THE PROBLEM :
        javadoc generates invalid HTML pages, if java source files have ftp:// links.
        The link is translated into a relative path as follows:
         java source file:
            <a href="ftp://www.domain.com/">FTP Site</a>
         generated page:
            <a href="../a/ftp://www.domain.com">FTP Site</a>

        The issue has reported in JDK-5044953, but yet has to be fixed.
        These errors may be included in the Java API documents in the future.
        It's a waste of time to modify the source every time a problem is found,
        that I would like to suggest the fix.
        The problem is that HtmlDocletWriter only checks certain tagas, mailto, http, https, and file.
        Regular expressions should be used to support all protocols.

        src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
         
        @@ -1623,11 +1623,7 @@ public class HtmlDocletWriter {
                if (redirectPathFromRoot == null) {
                    return text;
                }
        - String lower = Utils.toLowerCase(text);
        - if (!(lower.startsWith("mailto:")
        - || lower.startsWith("http:")
        - || lower.startsWith("https:")
        - || lower.startsWith("file:"))) {
        + if (!text.matches("^[^:/?#]+:.+$")) {
                    text = "{@" + (new DocRootTaglet()).getName() + "}/"
                            + redirectPathFromRoot.resolve(text).getPath();
                    text = replaceDocRootDir(text);

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. unzip attached JavadocTest.zip
           I will send it later.
        2. execute javadoc
           cd JavadocTest
           javadoc -J-Duser.language=us -d doc -notimestamp -use a
        3. check generated doc/a/package-use.html, doc/a/class-use/B1.StaticInnerB1.html
           and doc/index-all.html.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The link should be translated into an absolute path:
          <a href="ftp://www.domain.com">FTP Site</a>
        ACTUAL -
        The link becomes a relative path:
          <a href="../a/ftp://www.domain.com">FTP Site</a>

        ---------- BEGIN SOURCE ----------
        I can send JavadocTest.zip as a test case.
        ---------- END SOURCE ----------

        FREQUENCY : occasionally


        Attachments

          Issue Links

            Activity

              People

                prappo Pavel Rappo
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: