Merge

Wed, 25 Sep 2013 07:36:37 -0700

author
mfang
date
Wed, 25 Sep 2013 07:36:37 -0700
changeset 2059
6b702ace3e45
parent 2058
daa3bfb82e58
parent 2055
184c0d6698c3
child 2060
68292726000e

Merge

     1.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Tue Sep 24 14:35:24 2013 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java	Wed Sep 25 07:36:37 2013 -0700
     1.3 @@ -28,6 +28,7 @@
     1.4  import java.io.IOException;
     1.5  import java.io.Writer;
     1.6  import java.util.*;
     1.7 +import java.nio.charset.*;
     1.8  
     1.9  import com.sun.tools.doclets.internal.toolkit.Content;
    1.10  import com.sun.tools.doclets.internal.toolkit.util.*;
    1.11 @@ -164,6 +165,46 @@
    1.12      }
    1.13  
    1.14      /**
    1.15 +     * A set of ASCII URI characters to be left unencoded.
    1.16 +     */
    1.17 +    public static BitSet NONENCODING_CHARS = new BitSet(256);
    1.18 +
    1.19 +    static {
    1.20 +        // alphabetic characters
    1.21 +        for (int i = 'a'; i <= 'z'; i++) {
    1.22 +            NONENCODING_CHARS.set(i);
    1.23 +        }
    1.24 +        for (int i = 'A'; i <= 'Z'; i++) {
    1.25 +            NONENCODING_CHARS.set(i);
    1.26 +        }
    1.27 +        // numeric characters
    1.28 +        for (int i = '0'; i <= '9'; i++) {
    1.29 +            NONENCODING_CHARS.set(i);
    1.30 +        }
    1.31 +        // Reserved characters as per RFC 3986. These are set of delimiting characters.
    1.32 +        String noEnc = ":/?#[]@!$&'()*+,;=";
    1.33 +        // Unreserved characters as per RFC 3986 which should not be percent encoded.
    1.34 +        noEnc += "-._~";
    1.35 +        for (int i = 0; i < noEnc.length(); i++) {
    1.36 +            NONENCODING_CHARS.set(noEnc.charAt(i));
    1.37 +        }
    1.38 +    }
    1.39 +
    1.40 +    private static String encodeURL(String url) {
    1.41 +        byte[] urlBytes = url.getBytes(Charset.forName("UTF-8"));
    1.42 +        StringBuilder sb = new StringBuilder();
    1.43 +        for (int i = 0; i < urlBytes.length; i++) {
    1.44 +            int c = urlBytes[i];
    1.45 +            if (NONENCODING_CHARS.get(c & 0xFF)) {
    1.46 +                sb.append((char) c);
    1.47 +            } else {
    1.48 +                sb.append(String.format("%%%02X", c & 0xFF));
    1.49 +            }
    1.50 +        }
    1.51 +        return sb.toString();
    1.52 +    }
    1.53 +
    1.54 +    /**
    1.55       * Generates an HTML anchor tag.
    1.56       *
    1.57       * @param ref reference url for the anchor tag
    1.58 @@ -172,7 +213,7 @@
    1.59       */
    1.60      public static HtmlTree A(String ref, Content body) {
    1.61          HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body));
    1.62 -        htmltree.addAttr(HtmlAttr.HREF, ref);
    1.63 +        htmltree.addAttr(HtmlAttr.HREF, encodeURL(ref));
    1.64          return htmltree;
    1.65      }
    1.66  
     2.1 --- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue Sep 24 14:35:24 2013 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Wed Sep 25 07:36:37 2013 -0700
     2.3 @@ -335,6 +335,12 @@
     2.4                  "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
     2.5                  "        targetPage = \"undefined\";" + DocletConstants.NL +
     2.6                  "    function validURL(url) {" + DocletConstants.NL +
     2.7 +                "        try {" + DocletConstants.NL +
     2.8 +                "            url = decodeURIComponent(url);" + DocletConstants.NL +
     2.9 +                "        }" + DocletConstants.NL +
    2.10 +                "        catch (error) {" + DocletConstants.NL +
    2.11 +                "            return false;" + DocletConstants.NL +
    2.12 +                "        }" + DocletConstants.NL +
    2.13                  "        var pos = url.indexOf(\".html\");" + DocletConstants.NL +
    2.14                  "        if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
    2.15                  "            return false;" + DocletConstants.NL +
    2.16 @@ -346,7 +352,8 @@
    2.17                  "            if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
    2.18                  "                    'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
    2.19                  "                    ch == '$' ||" + DocletConstants.NL +
    2.20 -                "                    ch == '_') {" + DocletConstants.NL +
    2.21 +                "                    ch == '_' ||" + DocletConstants.NL +
    2.22 +                "                    ch.charCodeAt(0) > 127) {" + DocletConstants.NL +
    2.23                  "                allowNumber = true;" + DocletConstants.NL +
    2.24                  "                allowSep = true;" + DocletConstants.NL +
    2.25                  "            } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
     3.1 --- a/test/com/sun/javadoc/testHref/TestHref.java	Tue Sep 24 14:35:24 2013 -0700
     3.2 +++ b/test/com/sun/javadoc/testHref/TestHref.java	Wed Sep 25 07:36:37 2013 -0700
     3.3 @@ -23,7 +23,7 @@
     3.4  
     3.5  /*
     3.6   * @test
     3.7 - * @bug      4663254
     3.8 + * @bug      4663254 8016328
     3.9   * @summary  Verify that spaces do not appear in hrefs and anchors.
    3.10   * @author   jamieh
    3.11   * @library  ../lib/
    3.12 @@ -46,11 +46,11 @@
    3.13      private static final String[][] TEST = {
    3.14          //External link.
    3.15          {BUG_ID + FS + "pkg" + FS + "C1.html",
    3.16 -            "href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long, int)\""
    3.17 +            "href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long,%20int)\""
    3.18          },
    3.19          //Member summary table link.
    3.20          {BUG_ID + FS + "pkg" + FS + "C1.html",
    3.21 -            "href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\""
    3.22 +            "href=\"../pkg/C1.html#method(int,%20int,%20java.util.ArrayList)\""
    3.23          },
    3.24          //Anchor test.
    3.25          {BUG_ID + FS + "pkg" + FS + "C1.html",
    3.26 @@ -66,11 +66,11 @@
    3.27          },
    3.28          //{@link} test.
    3.29          {BUG_ID + FS + "pkg" + FS + "C2.html",
    3.30 -            "Link: <a href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
    3.31 +            "Link: <a href=\"../pkg/C1.html#method(int,%20int,%20java.util.ArrayList)\">"
    3.32          },
    3.33          //@see test.
    3.34          {BUG_ID + FS + "pkg" + FS + "C2.html",
    3.35 -            "See Also:</span></dt>" + NL + "<dd><a href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
    3.36 +            "See Also:</span></dt>" + NL + "<dd><a href=\"../pkg/C1.html#method(int,%20int,%20java.util.ArrayList)\">"
    3.37          },
    3.38  
    3.39          //Header does not link to the page itself.
     4.1 --- a/test/com/sun/javadoc/testJavascript/TestJavascript.java	Tue Sep 24 14:35:24 2013 -0700
     4.2 +++ b/test/com/sun/javadoc/testJavascript/TestJavascript.java	Wed Sep 25 07:36:37 2013 -0700
     4.3 @@ -23,7 +23,7 @@
     4.4  
     4.5  /*
     4.6   * @test
     4.7 - * @bug      4665566 4855876 7025314 8012375 8015997
     4.8 + * @bug      4665566 4855876 7025314 8012375 8015997 8016328
     4.9   * @summary  Verify that the output has the right javascript.
    4.10   * @author   jamieh
    4.11   * @library  ../lib/
    4.12 @@ -56,6 +56,12 @@
    4.13              "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + NL +
    4.14              "        targetPage = \"undefined\";" + NL +
    4.15              "    function validURL(url) {" + NL +
    4.16 +            "        try {" + NL +
    4.17 +            "            url = decodeURIComponent(url);" + NL +
    4.18 +            "        }" + NL +
    4.19 +            "        catch (error) {" + NL +
    4.20 +            "            return false;" + NL +
    4.21 +            "        }" + NL +
    4.22              "        var pos = url.indexOf(\".html\");" + NL +
    4.23              "        if (pos == -1 || pos != url.length - 5)" + NL +
    4.24              "            return false;" + NL +
    4.25 @@ -67,7 +73,8 @@
    4.26              "            if ('a' <= ch && ch <= 'z' ||" + NL +
    4.27              "                    'A' <= ch && ch <= 'Z' ||" + NL +
    4.28              "                    ch == '$' ||" + NL +
    4.29 -            "                    ch == '_') {" + NL +
    4.30 +            "                    ch == '_' ||" + NL +
    4.31 +            "                    ch.charCodeAt(0) > 127) {" + NL +
    4.32              "                allowNumber = true;" + NL +
    4.33              "                allowSep = true;" + NL +
    4.34              "            } else if ('0' <= ch && ch <= '9'" + NL +
     5.1 --- a/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java	Tue Sep 24 14:35:24 2013 -0700
     5.2 +++ b/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java	Wed Sep 25 07:36:37 2013 -0700
     5.3 @@ -23,7 +23,7 @@
     5.4  
     5.5  /*
     5.6   * @test
     5.7 - * @bug      4732864 6280605 7064544 8014636
     5.8 + * @bug      4732864 6280605 7064544 8014636 8016328
     5.9   * @summary  Make sure that you can link from one member to another using
    5.10   *           non-qualified name, furthermore, ensure the right one is linked.
    5.11   * @author   jamieh
    5.12 @@ -49,9 +49,9 @@
    5.13              "Qualified Link: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
    5.14              " Unqualified Link1: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
    5.15              " Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>" + NL +
    5.16 -            " Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>" + NL +
    5.17 -            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>" + NL +
    5.18 -            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(InnerC, InnerC2)</code></a>.<br/>"
    5.19 +            " Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC,%20pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>" + NL +
    5.20 +            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC,%20pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>" + NL +
    5.21 +            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC,%20pkg.C.InnerC2)\"><code>method(InnerC, InnerC2)</code></a>.<br/>"
    5.22          },
    5.23          {BUG_ID + FS + "pkg" + FS + "C.InnerC.html",
    5.24              "Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>" + NL +
     6.1 --- a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java	Tue Sep 24 14:35:24 2013 -0700
     6.2 +++ b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java	Wed Sep 25 07:36:37 2013 -0700
     6.3 @@ -23,7 +23,7 @@
     6.4  
     6.5  /*
     6.6   * @test
     6.7 - * @bug      4780441 4874845 4978816 8014017
     6.8 + * @bug      4780441 4874845 4978816 8014017 8016328
     6.9   * @summary  Make sure that when the -private flag is not used, members
    6.10   *           inherited from package private class are documented in the child.
    6.11   *
    6.12 @@ -177,7 +177,7 @@
    6.13          // Should document that a method overrides method from private class.
    6.14         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
    6.15              "<dt><span class=\"strong\">Overrides:</span></dt>" + NL +
    6.16 -            "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
    6.17 +            "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[],%20int,%20T,%20V,%20java.util.List)\">" +
    6.18              "methodOverridenFromParent</a></code>&nbsp;in class&nbsp;<code>" +
    6.19              "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
    6.20              "PrivateParent</a></code></dd>"},
     7.1 --- a/test/com/sun/javadoc/testUseOption/TestUseOption.java	Tue Sep 24 14:35:24 2013 -0700
     7.2 +++ b/test/com/sun/javadoc/testUseOption/TestUseOption.java	Wed Sep 25 07:36:37 2013 -0700
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -23,7 +23,7 @@
    7.11  
    7.12  /*
    7.13   * @test
    7.14 - * @bug 4496290 4985072 7006178 7068595
    7.15 + * @bug 4496290 4985072 7006178 7068595 8016328
    7.16   * @summary A simple test to determine if -use works.
    7.17   * @author jamieh
    7.18   * @library ../lib/
    7.19 @@ -60,7 +60,7 @@
    7.20                   "UsedInC</a> in <a href=\"../package-summary.html\">&lt;Unnamed&gt;</a>"
    7.21          },
    7.22          {BUG_ID + "-3" + FS + "package-use.html", "<td class=\"colOne\">" +
    7.23 -                 "<a href=\"class-use/UsedInC.html#&lt;Unnamed&gt;\">UsedInC</a>&nbsp;</td>"
    7.24 +                 "<a href=\"class-use/UsedInC.html#%3CUnnamed%3E\">UsedInC</a>&nbsp;</td>"
    7.25          }
    7.26      };
    7.27  

mercurial