Evolve, document how the URI path fix works. Fix 302 redirects so they URL encode properly. bump to -1
This commit is contained in:
@ -296,7 +296,13 @@ public class ResourceHandler extends AbstractHttpHandler
|
||||
log.debug("Redirect to directory/");
|
||||
|
||||
String q=request.getQuery();
|
||||
StringBuffer buf = URI.encodePath(null, request.getRequestURL().toString());
|
||||
|
||||
// Properly fix URI
|
||||
URI urifix = new URI(request.getRequestURL().toString());
|
||||
urifix.setPath(urifix.getPath());
|
||||
StringBuffer buf = new StringBuffer(urifix.toString());
|
||||
urifix = null;
|
||||
|
||||
if (q!=null&&q.length()!=0)
|
||||
{
|
||||
buf.append('?');
|
||||
|
@ -570,9 +570,14 @@ public class URI
|
||||
*/
|
||||
public static StringBuffer encodePath(StringBuffer buf, String path)
|
||||
{
|
||||
// Convert path to native first.
|
||||
/* Convert path to native character set not __CHARSET.
|
||||
* This is important to do this way because the path
|
||||
* contains *OS specific characters* and __CHARSET could
|
||||
* be wrong and not encode/decode the path correctly.
|
||||
*/
|
||||
byte[] b = null;
|
||||
/*
|
||||
Keep commented out unless you can prove that this does the right thing.
|
||||
try {
|
||||
b = path.getBytes(__CHARSET);
|
||||
} catch(UnsupportedEncodingException ex) {
|
||||
@ -604,12 +609,16 @@ public class URI
|
||||
char c = _path.charAt(i);
|
||||
String cs = "" + c;
|
||||
if(reserved.contains(cs) || !unreserved.contains(cs)) {
|
||||
/*
|
||||
We are already bytes
|
||||
if((c & 0xff) == c) {
|
||||
buf.append(gethex(c & 0xff));
|
||||
} else {
|
||||
buf.append(gethex((c >> 8) & 0xff));
|
||||
buf.append(gethex(c & 0xff));
|
||||
}
|
||||
*/
|
||||
buf.append(gethex(c & 0xff));
|
||||
} else {
|
||||
buf.append(c);
|
||||
}
|
||||
@ -717,6 +726,7 @@ public class URI
|
||||
return path;
|
||||
|
||||
/*
|
||||
Keep commented out unless you can prove that this does the right thing.
|
||||
try
|
||||
{
|
||||
return new String(bytes,0,n,__CHARSET);
|
||||
@ -752,6 +762,11 @@ public class URI
|
||||
/** Add two URI path segments.
|
||||
* Handles null and empty paths, path and query params (eg ?a=b or
|
||||
* ;JSESSIONID=xxx) and avoids duplicate '/'
|
||||
*
|
||||
* WARNING: URI path segments must be encoded properly first!
|
||||
* Use the encodePath method above BEFORE attaching a path
|
||||
* that contains characters that need escaping! --Sponge
|
||||
*
|
||||
* @param p1 URI path segment
|
||||
* @param p2 URI path segment
|
||||
* @return Legally combined path segments.
|
||||
|
@ -1,3 +1,10 @@
|
||||
2010-12-26 sponge
|
||||
* URI resource fixes from pre-review time from upstream prior merge
|
||||
* Evolve URI fixs another step.
|
||||
* Document how the URI path fix works.
|
||||
* Fix 302 redirects so they URL encode properly.
|
||||
* bump to -1
|
||||
|
||||
* 2010-12-22 0.8.2 released
|
||||
|
||||
2010-12-13 dr|z3d
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 0;
|
||||
public final static long BUILD = 1;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
Reference in New Issue
Block a user