/hg/release/icedtea7-forest-2.3/langtools: 2 new changesets

andrew at icedtea.classpath.org andrew at icedtea.classpath.org
Tue Oct 15 16:11:58 PDT 2013


changeset 06ac20b9a119 in /hg/release/icedtea7-forest-2.3/langtools
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.3/langtools?cmd=changeset;node=06ac20b9a119
author: bpatel
date: Fri Jul 19 16:02:59 2013 -0700

	8016675: Make Javadoc pages more robust
	Reviewed-by: jlaskey, ksrini


changeset 42a5c234b641 in /hg/release/icedtea7-forest-2.3/langtools
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.3/langtools?cmd=changeset;node=42a5c234b641
author: robm
date: Tue Jul 09 03:31:34 2013 +0100

	8016653: javadoc should ignore ignoreable characters in names
	Reviewed-by: jjg


diffstat:

 src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java |  49 +++++++++-
 src/share/classes/com/sun/tools/javac/parser/Scanner.java                   |  42 +++++---
 2 files changed, 74 insertions(+), 17 deletions(-)

diffs (158 lines):

diff -r f5971bf5bc5e -r 42a5c234b641 src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Thu Aug 08 23:17:58 2013 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java	Tue Jul 09 03:31:34 2013 +0100
@@ -292,7 +292,7 @@
             script.addAttr(HtmlAttr.TYPE, "text/javascript");
             String scriptCode = "<!--" + DocletConstants.NL +
                     "    if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
-                    "        parent.document.title=\"" + winTitle + "\";" + DocletConstants.NL +
+                    "        parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";" + DocletConstants.NL +
                     "    }" + DocletConstants.NL +
                     "//-->" + DocletConstants.NL;
             RawHtml scriptContent = new RawHtml(scriptCode);
@@ -302,6 +302,53 @@
     }
 
     /**
+     * Returns a String with escaped special JavaScript characters.
+     *
+     * @param s String that needs to be escaped
+     * @return a valid escaped JavaScript string
+     */
+    private static String escapeJavaScriptChars(String s) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s.charAt(i);
+            switch (ch) {
+                case '\b':
+                    sb.append("\\b");
+                    break;
+                case '\t':
+                    sb.append("\\t");
+                    break;
+                case '\n':
+                    sb.append("\\n");
+                    break;
+                case '\f':
+                    sb.append("\\f");
+                    break;
+                case '\r':
+                    sb.append("\\r");
+                    break;
+                case '"':
+                    sb.append("\\\"");
+                    break;
+                case '\'':
+                    sb.append("\\\'");
+                    break;
+                case '\\':
+                    sb.append("\\\\");
+                    break;
+                default:
+                    if (ch < 32 || ch >= 127) {
+                        sb.append(String.format("\\u%04X", (int)ch));
+                    } else {
+                        sb.append(ch);
+                    }
+                    break;
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
      * Returns a content tree for the SCRIPT tag for the main page(index.html).
      *
      * @return a content for the SCRIPT tag
diff -r f5971bf5bc5e -r 42a5c234b641 src/share/classes/com/sun/tools/javac/parser/Scanner.java
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Thu Aug 08 23:17:58 2013 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Tue Jul 09 03:31:34 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -501,11 +501,10 @@
     private void scanIdent() {
         boolean isJavaIdentifierPart;
         char high;
+        if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
+        // optimization, was: putChar(ch);
+        scanChar();
         do {
-            if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
-            // optimization, was: putChar(ch);
-
-            scanChar();
             switch (ch) {
             case 'A': case 'B': case 'C': case 'D': case 'E':
             case 'F': case 'G': case 'H': case 'I': case 'J':
@@ -522,6 +521,7 @@
             case '$': case '_':
             case '0': case '1': case '2': case '3': case '4':
             case '5': case '6': case '7': case '8': case '9':
+                break;
             case '\u0000': case '\u0001': case '\u0002': case '\u0003':
             case '\u0004': case '\u0005': case '\u0006': case '\u0007':
             case '\u0008': case '\u000E': case '\u000F': case '\u0010':
@@ -529,30 +529,37 @@
             case '\u0015': case '\u0016': case '\u0017':
             case '\u0018': case '\u0019': case '\u001B':
             case '\u007F':
-                break;
+                scanChar();
+                continue;
             case '\u001A': // EOI is also a legal identifier part
                 if (bp >= buflen) {
                     name = names.fromChars(sbuf, 0, sp);
                     token = keywords.key(name);
                     return;
                 }
-                break;
+                scanChar();
+                continue;
             default:
                 if (ch < '\u0080') {
                     // all ASCII range chars already handled, above
                     isJavaIdentifierPart = false;
                 } else {
-                    high = scanSurrogates();
-                    if (high != 0) {
-                        if (sp == sbuf.length) {
-                            putChar(high);
+                    if (Character.isIdentifierIgnorable(ch)) {
+                        scanChar();
+                        continue;
+                    } else {
+                        high = scanSurrogates();
+                        if (high != 0) {
+                            if (sp == sbuf.length) {
+                                putChar(high);
+                            } else {
+                                sbuf[sp++] = high;
+                            }
+                            isJavaIdentifierPart = Character.isJavaIdentifierPart(
+                                Character.toCodePoint(high, ch));
                         } else {
-                            sbuf[sp++] = high;
+                            isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
                         }
-                        isJavaIdentifierPart = Character.isJavaIdentifierPart(
-                            Character.toCodePoint(high, ch));
-                    } else {
-                        isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
                     }
                 }
                 if (!isJavaIdentifierPart) {
@@ -561,6 +568,9 @@
                     return;
                 }
             }
+            if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
+            // optimization, was: putChar(ch);
+            scanChar();
         } while (true);
     }
 


More information about the distro-pkg-dev mailing list