Changeset 13353 for trunk/abcl/src/org


Ignore:
Timestamp:
06/21/11 10:11:10 (10 years ago)
Author:
Mark Evenson
Message:

Fix problems with whitespace in JAR-PATHNAME.

For dealing with URI Encoding (also known as [Percent Encoding]() we
implement the following rules which were implicitly.

[Percent Encoding]: http://en.wikipedia.org/wiki/Percent-encoding

  1. All pathname components are represented "as is" without escaping.
  1. Namestrings are suitably escaped if the Pathname is a URL-PATHNAME

or a JAR-PATHNAME.

  1. Namestrings should all "round-trip":

(when (typep p 'pathname)

(equal (namestring p)

(namestring (pathname p))))

Users may use EXT:URI-ENCODE and EXT:URI-DECODE to access the escaping
rules in circumstances where they wish to manipulate PATHNAME
namestrings more directly.

All tests in JAR-PATHNAMES now pass.

Constructors for PATHNAME now produce ERROR rather than FILE-ERROR as
CLHS says "The type file-error consists of error conditions that occur
during an attempt to open or close a file, or during some low-level
transactions with a file system," which doesn't apply here.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Load.java

    r13274 r13353  
    154154        if (Utilities.checkZipFile(truename)) {
    155155            String n = truename.getNamestring();
    156             n = Pathname.uriEncode(n);
     156            String name = Pathname.uriEncode(truename.name.getStringValue());
    157157            if (n.startsWith("jar:")) {
    158                 n = "jar:" + n + "!/" + truename.name.getStringValue() + "."
     158                n = "jar:" + n + "!/" + name + "."
    159159                    + COMPILE_FILE_INIT_FASL_TYPE;
    160160            } else {
    161                 n = "jar:file:" + n + "!/" + truename.name.getStringValue() + "."
     161                n = "jar:file:" + n + "!/" + name + "."
    162162                    + COMPILE_FILE_INIT_FASL_TYPE;
    163163            }
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r13349 r13353  
    281281                        uri = url.toURI();
    282282                    } catch (MalformedURLException e1) {
    283                         error(new FileError("Failed to create URI from "
     283                        error(new SimpleError("Failed to create URI from "
    284284                                            + "'" + file + "'"
    285285                                            + ": " + e1.getMessage()));
    286286                    } catch (URISyntaxException e2) {
    287                         error(new FileError("Failed to create URI from "
     287                        error(new SimpleError("Failed to create URI from "
    288288                                            + "'" + file + "'"
    289289                                            + ": " + e2.getMessage()));
     
    327327                url = new URL(jarURL);
    328328            } catch (MalformedURLException ex) {
    329                 error(new FileError("Failed to parse URL "
     329                error(new LispError("Failed to parse URL "
    330330                                    + "'" + jarURL + "'"
    331331                                    + ex.getMessage()));
     
    340340            }
    341341            s = "/" + s.substring(separatorIndex + jarSeparator.length());
    342             Pathname p = new Pathname(s);
     342            Pathname p = new Pathname("file:" + s); // Use URI escaping rules
    343343            directory = p.directory;
    344344            name = p.name;
     
    362362                    uri = url.toURI();
    363363                } catch (URISyntaxException ex) {
    364                     error(new FileError("Improper URI syntax for "
     364                    error(new SimpleError("Improper URI syntax for "
    365365                                    + "'" + url.toString() + "'"
    366366                                    + ": " + ex.toString()));
     
    368368                final String uriPath = uri.getPath();
    369369                if (null == uriPath) {
    370                     error(new FileError("The URI has no path: " + uri));
     370                    error(new LispError("The URI has no path: " + uri));
    371371                }
    372372                final File file = new File(uriPath);
     
    24882488        return null;  // Error
    24892489    }
    2490 
    2491 
    2492     @DocString(name="uri-encode",
     2490   
     2491        @DocString(name="uri-encode",
    24932492               args="string => string",
    24942493               doc="Encode percent escape sequences in the manner of URI encodings.")
Note: See TracChangeset for help on using the changeset viewer.