提交 7b78dcc7 编写于 作者: J juh

8005389: Backout fix for JDK-6500133

Reviewed-by: mullan
上级 26cdda46
...@@ -30,7 +30,6 @@ import java.net.URI; ...@@ -30,7 +30,6 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import sun.security.util.*; import sun.security.util.*;
import sun.net.www.ParseUtil;
/** /**
* This class implements the URIName as required by the GeneralNames * This class implements the URIName as required by the GeneralNames
...@@ -107,13 +106,7 @@ public class URIName implements GeneralNameInterface { ...@@ -107,13 +106,7 @@ public class URIName implements GeneralNameInterface {
try { try {
uri = new URI(name); uri = new URI(name);
} catch (URISyntaxException use) { } catch (URISyntaxException use) {
try { throw new IOException("invalid URI name:" + name, use);
// 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);
}
} }
if (uri.getScheme() == null) { if (uri.getScheme() == null) {
throw new IOException("URI name must include scheme:" + name); throw new IOException("URI name must include scheme:" + name);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,11 +23,12 @@ ...@@ -23,11 +23,12 @@
/* /*
* @test * @test
* @bug 6500133 * @bug 8005389
* @summary CRL Distribution Point URIs with spaces or backslashes should be * @summary CRL Distribution Point URIs with spaces or backslashes should
* parseable * not be parseable
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import sun.security.util.DerValue; import sun.security.util.DerValue;
...@@ -90,27 +91,45 @@ public class Parse { ...@@ -90,27 +91,45 @@ public class Parse {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
/* Parse a CRLDistributionPointsExtension URI with a space. */ /* Try to parse a CRLDistributionPointsExtension URI with a space. */
try {
CRLDistributionPointsExtensionTest(certWithSpaceInCDPStr); CRLDistributionPointsExtensionTest(certWithSpaceInCDPStr);
System.out.println("Parsed CRLDistributionPointsExtension uri with " throw new RuntimeException("Illegally parsed a "
+ "a space."); + "CRLDistributionPointsExtension uri with a space.");
} catch (IOException e) {
System.out.println("Caught the correct exception.");
/* Parse a CRLDistributionPointsExtension URI with backslashes. */ }
/* Try to parse a CRLDistributionPointsExtension URI with backslashes. */
try {
CRLDistributionPointsExtensionTest(certWithBackslashesInCDPStr); CRLDistributionPointsExtensionTest(certWithBackslashesInCDPStr);
System.out.println("Parsed CRLDistributionPointsExtension uri with " throw new RuntimeException("Illegally parsed a "
+ "backslashes."); + "CRLDistributionPointsExtension uri with a backslashes.");
} catch (IOException e) {
System.out.println("Caught the correct exception.");
}
/* Constructor a URIName from a uri with a space. */ /* Try to construct a URIName from a uri with a space. */
String uriWithSpace = "file://crl file.crl"; String uriWithSpace = "file://crl file.crl";
URIName name = new URIName(uriWithSpace); URIName name;
System.out.println("URI re-encoded from " + uriWithSpace try {
+ " to " + name.getName()); 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"; String uriWithBackslashes = "file://\\\\CRL\\crl_file.crl";
try {
name = new URIName(uriWithBackslashes); name = new URIName(uriWithBackslashes);
System.out.println("URI re-encoded from " + uriWithBackslashes throw new RuntimeException("Illegally created a URIName "
+ " to " + name.getName()); + "from a uri with backslashes.");
} catch (IOException e) {
System.out.println("Caught the correct exception.");
}
System.out.println("Tests passed."); System.out.println("Tests passed.");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册