Changeset 965b2611 for apps/jetty


Ignore:
Timestamp:
Dec 26, 2010 8:45:29 PM (10 years ago)
Author:
sponge <sponge@…>
Branches:
master
Children:
f225c1c
Parents:
923c3d8
Message:

Evolve, document how the URI path fix works. Fix 302 redirects so they URL encode properly. bump to -1

Location:
apps/jetty/java/src/org/mortbay
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/jetty/java/src/org/mortbay/http/handler/ResourceHandler.java

    r923c3d8 r965b2611  
    297297                   
    298298                    String q=request.getQuery();
    299                     StringBuffer buf = URI.encodePath(null, request.getRequestURL().toString());
     299                   
     300                    // Properly fix URI
     301                    URI urifix = new URI(request.getRequestURL().toString());
     302                    urifix.setPath(urifix.getPath());
     303                    StringBuffer buf = new StringBuffer(urifix.toString());
     304                    urifix = null;
     305                   
    300306                    if (q!=null&&q.length()!=0)
    301307                    {
  • apps/jetty/java/src/org/mortbay/util/URI.java

    r923c3d8 r965b2611  
    571571    public static StringBuffer encodePath(StringBuffer buf, String path)
    572572    {
    573         // Convert path to native first.
     573        /* Convert path to native character set not __CHARSET.
     574         * This is important to do this way because the path
     575         * contains *OS specific characters* and __CHARSET could
     576         * be wrong and not encode/decode the path correctly.
     577         */
    574578        byte[] b = null;
    575579        /*
     580        Keep commented out unless you can prove that this does the right thing.
    576581        try {
    577582            b = path.getBytes(__CHARSET);
     
    605610                String cs = "" + c;
    606611                if(reserved.contains(cs) || !unreserved.contains(cs)) {
     612                    /*
     613                    We are already bytes
    607614                    if((c & 0xff) == c) {
    608615                        buf.append(gethex(c & 0xff));
     
    611618                        buf.append(gethex(c & 0xff));
    612619                    }
     620                    */
     621                    buf.append(gethex(c & 0xff));
    613622                } else {
    614623                    buf.append(c);
     
    718727
    719728        /*
     729        Keep commented out unless you can prove that this does the right thing.
    720730        try
    721731        {   
     
    753763     * Handles null and empty paths, path and query params (eg ?a=b or
    754764     * ;JSESSIONID=xxx) and avoids duplicate '/'
     765     *
     766     * WARNING: URI path segments must be encoded properly first!
     767     *          Use the encodePath method above BEFORE attaching a path
     768     *          that contains characters that need escaping! --Sponge
     769     *
    755770     * @param p1 URI path segment
    756771     * @param p2 URI path segment
Note: See TracChangeset for help on using the changeset viewer.