7049963: DISTINGUISHED NAMES FOR CERT ARE ESCAPED IN JROCKIT 1.6(NOT COMPATIBLE WITH JROC
authormbankal
Wed, 14 Sep 2011 21:43:42 -0700
changeset 10590 f184672e4617
parent 10587 654c00a794b6
child 10591 da82afe84ad8
7049963: DISTINGUISHED NAMES FOR CERT ARE ESCAPED IN JROCKIT 1.6(NOT COMPATIBLE WITH JROC Reviewed-by: mullan
jdk/src/share/classes/sun/security/x509/AVA.java
--- a/jdk/src/share/classes/sun/security/x509/AVA.java	Wed Sep 14 08:33:34 2011 -0700
+++ b/jdk/src/share/classes/sun/security/x509/AVA.java	Wed Sep 14 21:43:42 2011 -0700
@@ -1071,8 +1071,17 @@
                  * to need quoting, or at least escaping.  So do leading or
                  * trailing spaces, and multiple internal spaces.
                  */
-                for (int i = 0; i < valStr.length(); i++) {
+                int length = valStr.length();
+                boolean alreadyQuoted =
+                    (length > 1 && valStr.charAt(0) == '\"'
+                     && valStr.charAt(length - 1) == '\"');
+
+                for (int i = 0; i < length; i++) {
                     char c = valStr.charAt(i);
+                    if (alreadyQuoted && (i == 0 || i == length - 1)) {
+                        sbuffer.append(c);
+                        continue;
+                    }
                     if (DerValue.isPrintableStringChar(c) ||
                         escapees.indexOf(c) >= 0) {
 
@@ -1136,7 +1145,8 @@
                 }
 
                 // Emit the string ... quote it if needed
-                if (quoteNeeded) {
+                // if string is already quoted, don't re-quote
+                if (!alreadyQuoted && quoteNeeded) {
                     retval.append("\"" + sbuffer.toString() + "\"");
                 } else {
                     retval.append(sbuffer.toString());