提交 55a287b9 编写于 作者: K kohsuke

[fixed] Perform RFC2396 style escape. I suppose the proper fix is to change...

[fixed] Perform RFC2396 style escape. I suppose the proper fix is to change the signature to return URI so that it works better with chaining (issue #1464)


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8281 71c3de6d-444a-0410-be80-ed276b4c234a
上级 cd486a06
......@@ -27,6 +27,8 @@ import java.io.Writer;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......@@ -696,6 +698,23 @@ public class Util {
}
}
/**
* Encodes the URL by RFC 2396.
*
* I thought there's another spec that refers to UTF-8 as the encoding,
* but don't remember it right now.
*
* @since 1.204
*/
public static String encodeRFC2396(String url) {
try {
return new URI(null,url,null).toASCIIString();
} catch (URISyntaxException e) {
LOGGER.warning("Failed to encode "+url); // could this ever happen?
return url;
}
}
/**
* Wraps with the error icon and the CSS class to render error message.
* @since 1.173
......
......@@ -156,8 +156,8 @@ public final class MavenArtifact implements Serializable {
* Called from within Maven to archive an artifact in Hudson.
*/
public void archive(MavenBuildProxy build, File file, BuildListener listener) throws IOException, InterruptedException {
listener.getLogger().println("[HUDSON] Archiving "+ file);
FilePath target = getArtifactArchivePath(build,groupId,artifactId,version);
listener.getLogger().println("[HUDSON] Archiving "+ file+" to "+target);
new FilePath(file).copyTo(target);
/* debug probe to investigate "missing artifact" problem typically seen like this:
......
......@@ -12,6 +12,7 @@ import org.kohsuke.stapler.export.ExportedBean;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.net.URI;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
......@@ -150,7 +151,7 @@ public abstract class AbstractItem extends Actionable implements Item {
StaplerRequest request = Stapler.getCurrentRequest();
if(request==null)
throw new IllegalStateException("Not processing a HTTP request");
return request.getRootPath()+'/'+getUrl();
return Util.encodeRFC2396(request.getRootPath()+'/'+getUrl());
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册