changeset 15268:d815f9973d97

8005389: Backout fix for JDK-6500133 Reviewed-by: mullan
author juh
date Wed, 16 Jan 2013 09:51:21 -0500
parents c884f548a25f
children 0a626adb5cc0
files jdk/src/share/classes/sun/security/x509/URIName.java jdk/test/sun/security/x509/URIName/Parse.java
diffstat 2 files changed, 40 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/classes/sun/security/x509/URIName.java	Wed Jan 16 12:09:35 2013 +0000
+++ b/jdk/src/share/classes/sun/security/x509/URIName.java	Wed Jan 16 09:51:21 2013 -0500
@@ -30,7 +30,6 @@
 import java.net.URISyntaxException;
 
 import sun.security.util.*;
-import sun.net.www.ParseUtil;
 
 /**
  * This class implements the URIName as required by the GeneralNames
@@ -107,13 +106,7 @@
         try {
             uri = new URI(name);
         } catch (URISyntaxException use) {
-            try {
-                // Try parsing the URI again after encoding/escaping
-                // any illegal characters
-                uri = new URI(ParseUtil.encodePath(name));
-            } catch (URISyntaxException use2) {
-                throw new IOException("invalid URI name:" + name, use2);
-            }
+            throw new IOException("invalid URI name:" + name, use);
         }
         if (uri.getScheme() == null) {
             throw new IOException("URI name must include scheme:" + name);
--- a/jdk/test/sun/security/x509/URIName/Parse.java	Wed Jan 16 12:09:35 2013 +0000
+++ b/jdk/test/sun/security/x509/URIName/Parse.java	Wed Jan 16 09:51:21 2013 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,11 +23,12 @@
 
 /*
  * @test
- * @bug 6500133
- * @summary CRL Distribution Point URIs with spaces or backslashes should be
- *          parseable
+ * @bug 8005389
+ * @summary CRL Distribution Point URIs with spaces or backslashes should
+ *          not be parseable
  */
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import sun.security.util.DerValue;
@@ -90,27 +91,45 @@
     }
 
     public static void main(String[] args) throws Exception {
-        /* Parse a CRLDistributionPointsExtension URI with a space. */
-        CRLDistributionPointsExtensionTest(certWithSpaceInCDPStr);
-        System.out.println("Parsed CRLDistributionPointsExtension uri with "
-                            + "a space.");
+        /* Try to parse a CRLDistributionPointsExtension URI with a space. */
+        try {
+            CRLDistributionPointsExtensionTest(certWithSpaceInCDPStr);
+            throw new RuntimeException("Illegally parsed a "
+                    + "CRLDistributionPointsExtension uri with a space.");
+        } catch (IOException e) {
+            System.out.println("Caught the correct exception.");
 
-        /* Parse a CRLDistributionPointsExtension URI with backslashes. */
-        CRLDistributionPointsExtensionTest(certWithBackslashesInCDPStr);
-        System.out.println("Parsed CRLDistributionPointsExtension uri with "
-                            + "backslashes.");
+        }
 
-        /* Constructor a URIName from a uri with a space. */
+        /* Try to parse a CRLDistributionPointsExtension URI with backslashes. */
+        try {
+            CRLDistributionPointsExtensionTest(certWithBackslashesInCDPStr);
+            throw new RuntimeException("Illegally parsed a "
+                    + "CRLDistributionPointsExtension uri with a backslashes.");
+        } catch (IOException e) {
+            System.out.println("Caught the correct exception.");
+        }
+
+        /* Try to construct a URIName from a uri with a space. */
         String uriWithSpace = "file://crl file.crl";
-        URIName name = new URIName(uriWithSpace);
-        System.out.println("URI re-encoded from " + uriWithSpace
-                            + " to " + name.getName());
+        URIName name;
+        try {
+            name = new URIName(uriWithSpace);
+            throw new RuntimeException("Illegally created a URIName "
+                    + "from a uri with a space.");
+        } catch (IOException e) {
+            System.out.println("Caught the correct exception.");
+        }
 
-        /* Construct a URIName from a uri with backslashes. */
+        /* Try to construct a URIName from a uri with backslashes. */
         String uriWithBackslashes = "file://\\\\CRL\\crl_file.crl";
-        name = new URIName(uriWithBackslashes);
-        System.out.println("URI re-encoded from " + uriWithBackslashes
-                            + " to " + name.getName());
+        try {
+            name = new URIName(uriWithBackslashes);
+            throw new RuntimeException("Illegally created a URIName "
+                    + "from a uri with backslashes.");
+        } catch (IOException e) {
+            System.out.println("Caught the correct exception.");
+        }
 
         System.out.println("Tests passed.");
     }