[armedbear-cvs] r13026 - in trunk/abcl: src/org/armedbear/lisp test/lisp/abcl
Mark Evenson
mevenson at common-lisp.net
Wed Nov 17 15:55:48 UTC 2010
Author: mevenson
Date: Wed Nov 17 10:55:47 2010
New Revision: 13026
Log:
Further fix for #110 eliminating the use of the URLDecoder.decode().
Upon further review, the attempt to decode a URL path via the URL
unescaping functions intended for escaping HTML Forms submission is
just wrong, originating as far as I can tell in my initial Pathname
commit. There may be issues where we should treat strings of the form
'file:URI' with real URI escaping rules to remove %bb byte-encoding,
but these rules might well confuse those attempting to include '%' in
files, so we leave that to more formal specification.
Untabify Pathname.java.
Tests for correct parsing of device under Windows.
Modified:
trunk/abcl/src/org/armedbear/lisp/Pathname.java
trunk/abcl/test/lisp/abcl/jar-pathname.lisp
trunk/abcl/test/lisp/abcl/pathname-tests.lisp
Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java Wed Nov 17 10:55:47 2010
@@ -196,28 +196,18 @@
public Pathname(URL url) {
if ("file".equals(url.getProtocol())) {
- String s;
- try {
- s = URLDecoder.decode(url.getPath(), "UTF-8");
- // But rencode \SPACE as '+'
- s = s.replace(' ', '+');
- } catch (java.io.UnsupportedEncodingException uee) {
- // Can't happen: every Java is supposed to support
- // at least UTF-8 encoding
- Debug.assertTrue(false);
- s = null;
- }
+ String s = url.getPath();
if (s != null) {
- if (Utilities.isPlatformWindows) {
- // Workaround for Java's idea of URLs
- // new (URL"file:///c:/a/b").getPath() --> "/c:/a/b"
+ if (Utilities.isPlatformWindows) {
+ // Workaround for Java's idea of URLs
+ // new (URL"file:///c:/a/b").getPath() --> "/c:/a/b"
// whereas we need "c" to be the DEVICE.
- if (s.length() > 2
- && s.charAt(0) == '/'
- && s.charAt(2) == ':') {
- s = s.substring(1);
- }
- }
+ if (s.length() > 2
+ && s.charAt(0) == '/'
+ && s.charAt(2) == ':') {
+ s = s.substring(1);
+ }
+ }
init(s);
return;
}
@@ -653,13 +643,13 @@
sb.append('.');
if (type instanceof AbstractString) {
String t = type.getStringValue();
- // Allow Windows shortcuts to include TYPE
- if (!(t.endsWith(".lnk") && Utilities.isPlatformWindows)) {
- if (t.indexOf('.') >= 0) {
- Debug.assertTrue(namestring == null);
- return null;
- }
- }
+ // Allow Windows shortcuts to include TYPE
+ if (!(t.endsWith(".lnk") && Utilities.isPlatformWindows)) {
+ if (t.indexOf('.') >= 0) {
+ Debug.assertTrue(namestring == null);
+ return null;
+ }
+ }
sb.append(t);
} else if (type == Keyword.WILD) {
sb.append('*');
@@ -2106,12 +2096,12 @@
result = Utilities.getEntryAsInputStream(zipInputStream, entryPath);
} else {
ZipEntry entry = jarFile.getEntry(entryPath);
- if (entry == null) {
- Debug.trace("Failed to get InputStream for "
- + "'" + getNamestring() + "'");
+ if (entry == null) {
+ Debug.trace("Failed to get InputStream for "
+ + "'" + getNamestring() + "'");
// XXX should this be fatal?
- Debug.assertTrue(false);
- }
+ Debug.assertTrue(false);
+ }
try {
result = jarFile.getInputStream(entry);
} catch (IOException e) {
@@ -2280,7 +2270,7 @@
final File destination = new File(newNamestring);
if (Utilities.isPlatformWindows) {
if (destination.isFile()) {
- ZipCache.remove(destination);
+ ZipCache.remove(destination);
destination.delete();
}
}
@@ -2340,19 +2330,19 @@
}
public URL toURL() throws MalformedURLException {
- if(isURL()) {
- return new URL(getNamestring());
- } else {
- return toFile().toURL();
- }
+ if(isURL()) {
+ return new URL(getNamestring());
+ } else {
+ return toFile().toURL();
+ }
}
public File toFile() {
- if(!isURL()) {
- return new File(getNamestring());
- } else {
- throw new RuntimeException(this + " does not represent a file");
- }
+ if(!isURL()) {
+ return new File(getNamestring());
+ } else {
+ throw new RuntimeException(this + " does not represent a file");
+ }
}
static {
Modified: trunk/abcl/test/lisp/abcl/jar-pathname.lisp
==============================================================================
--- trunk/abcl/test/lisp/abcl/jar-pathname.lisp (original)
+++ trunk/abcl/test/lisp/abcl/jar-pathname.lisp Wed Nov 17 10:55:47 2010
@@ -341,6 +341,19 @@
(:relative "a" "b") "foo" "jar"
(:absolute "c" "d") "foo" "lisp")
+(deftest jar-pathname.10
+ (let ((s "jar:file:/foo/bar/a space/that!/this"))
+ (equal s
+ (namestring (pathname s))))
+ t)
+
+(deftest jar-pathname.11
+ (let ((s "jar:file:/foo/bar/a+space/that!/this"))
+ (equal s
+ (namestring (pathname s))))
+ t)
+
+
(deftest jar-pathname.match-p.1
(pathname-match-p "jar:file:/a/b/some.jar!/a/system/def.asd"
"jar:file:/**/*.jar!/**/*.asd")
Modified: trunk/abcl/test/lisp/abcl/pathname-tests.lisp
==============================================================================
--- trunk/abcl/test/lisp/abcl/pathname-tests.lisp (original)
+++ trunk/abcl/test/lisp/abcl/pathname-tests.lisp Wed Nov 17 10:55:47 2010
@@ -438,6 +438,21 @@
(equal #p"c:\\foo.bar" #p"C:\\FOO.BAR")
t)
+#+windows
+(deftest pathname.windows.6
+ (equal (pathname-device #p"z:/foo/bar") "z")
+ t)
+
+#+windows
+(deftest pathname.windows.7
+ (equal (pathname-device #p"file:z:/foo/bar") "z")
+ t)
+
+#+windows
+(deftest pathname.windows.8
+ (equal (pathname-device #p"zoo:/foo/bar") nil)
+ t)
+
(deftest wild.1
(check-physical-pathname #p"foo.*" nil "foo" :wild)
t)
More information about the armedbear-cvs
mailing list