Mercurial > hg > icedtea7-forest-aarch64 > langtools
changeset 1681:00eaa9e78c47
7052170: javadoc -charset option generates wrong meta tag
Reviewed-by: jjg
author | igerasim |
---|---|
date | Sun, 09 Feb 2014 20:41:25 +0400 |
parents | 772aad4e9681 |
children | 420dc86b1716 |
files | src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java test/com/sun/javadoc/testCharset/TestCharset.java test/com/sun/javadoc/testCharset/pkg/Foo.java |
diffstat | 6 files changed, 114 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Thu Jan 16 11:52:25 2014 -0800 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Sun Feb 09 20:41:25 2014 +0400 @@ -426,7 +426,7 @@ head.addContent(headComment); } if (configuration.charset.length() > 0) { - Content meta = HtmlTree.META("Content-Type", "text/html", + Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, configuration.charset); head.addContent(meta); }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Thu Jan 16 11:52:25 2014 -0800 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java Sun Feb 09 20:41:25 2014 +0400 @@ -35,7 +35,6 @@ BORDER, CELLPADDING, CELLSPACING, - CHARSET, CLASS, CLEAR, COLS,
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Thu Jan 16 11:52:25 2014 -0800 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java Sun Feb 09 20:41:25 2014 +0400 @@ -44,6 +44,8 @@ */ public abstract class HtmlDocWriter extends HtmlWriter { + public static final String CONTENT_TYPE = "text/html"; + /** * Constructor. Initializes the destination file name through the super * class HtmlWriter. @@ -328,7 +330,7 @@ head.addContent(headComment); } if (configuration.charset.length() > 0) { - Content meta = HtmlTree.META("Content-Type", "text/html", + Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE, configuration.charset); head.addContent(meta); }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java Thu Jan 16 11:52:25 2014 -0800 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java Sun Feb 09 20:41:25 2014 +0400 @@ -430,9 +430,9 @@ */ public static HtmlTree META(String httpEquiv, String content, String charSet) { HtmlTree htmltree = new HtmlTree(HtmlTag.META); + String contentCharset = content + "; charset=" + charSet; htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv)); - htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content)); - htmltree.addAttr(HtmlAttr.CHARSET, nullCheck(charSet)); + htmltree.addAttr(HtmlAttr.CONTENT, contentCharset); return htmltree; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testCharset/TestCharset.java Sun Feb 09 20:41:25 2014 +0400 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7052170 + * @summary Run a test on -charset to make sure the charset gets generated as a + * part of the meta tag. + * @author Bhavesh Patel + * @library ../lib/ + * @build JavadocTester TestCharset + * @run main TestCharset + */ + +public class TestCharset extends JavadocTester { + + //Test information. + private static final String BUG_ID = "7052170"; + + //Javadoc arguments. + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-charset", "UTF-8", "-sourcepath", SRC_DIR, "pkg" + }; + + private static final String[][] TEST = { + {BUG_ID + FS + "index.html", + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"}, + {BUG_ID + FS + "pkg" + FS + "Foo.html", + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"} + }; + + private static final String[][] NEGATED_TEST = { + {BUG_ID + FS + "index.html", + "<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">"}, + {BUG_ID + FS + "pkg" + FS + "Foo.html", + "<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\">"} + }; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + TestCharset tester = new TestCharset(); + run(tester, ARGS, TEST, NEGATED_TEST); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testCharset/pkg/Foo.java Sun Feb 09 20:41:25 2014 +0400 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package pkg; + +public class Foo {}