Test for java.net.URL
Pavel Roskin
pavel_roskin at geocities.com
Wed Jun 16 02:59:57 PDT 1999
Hello!
The attached program could eventually become part of the test-suite.
Currently it shows quite different results for JDK and kaffe.
$ kaffe badURL
file:abc
http://www.kaffe.org/
file:/etc/passwd
file:/etc/passwd/
bad
ftp://sunsite.unc.edu/pub/
file://sunsite.unc.edu/pub/
file:/etc/passwd/
bad
http://intranetserver
http://intranet-server
http://intranet-server/~onick
ftp://onick@intranet-server/public-html
http:/www.kaffe.org/
http:/www.kaffe.org/
$ /usr/local/java/bin/java badURL
bad
http://www.kaffe.org/
bad
bad
gopher://gopher.ibm.com/
ftp://sunsite.unc.edu/pub/
file://sunsite.unc.edu/pub/
file:/etc/passwd/
bad
http://intranetserver/
http://intranet-server/
http://intranet-server/~onick
ftp://onick@intranet-server/public-html
http:/www.kaffe.org/
http:/www.kaffe.org/
Pavel Roskin
-------------- next part --------------
import java.net.URL;
import java.net.MalformedURLException;
class badURL
{
public static void main (String[] argv)
{
URL url;
String urls;
String[] patterns = {
"abc",
"http://www.kaffe.org/",
"/etc/passwd",
"/etc/passwd/",
"gopher://gopher.ibm.com/",
"ftp://sunsite.unc.edu/pub/",
"file://sunsite.unc.edu/pub/",
"file:/etc/passwd/",
"foo:/dev/null",
"http://intranetserver",
"http://intranet-server",
"http://intranet-server/~onick",
"ftp://onick@intranet-server/public-html",
"http:/www.kaffe.org/",
"http:///www.kaffe.org/",
null
};
for (int i = 0; patterns[i] != null; i++) {
try {
url = new URL(patterns[i]);
urls = url.toString();
} catch (MalformedURLException e) {
urls = "bad";
}
System.out.println(urls);
}
}
}
More information about the kaffe
mailing list