diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 9025a6d70c99d760fb22a2eb680d812be28f8eeb..4f5c8139be3017869af483c2d76ed6d6e9b6ae8f 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -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 diff --git a/core/src/main/java/hudson/maven/reporters/MavenArtifact.java b/core/src/main/java/hudson/maven/reporters/MavenArtifact.java index 0a2b8585ed25f0d84a70caa119e83566a900fc66..82ed67f4e35c17c43a87dc2dd269b6f194f65a4f 100644 --- a/core/src/main/java/hudson/maven/reporters/MavenArtifact.java +++ b/core/src/main/java/hudson/maven/reporters/MavenArtifact.java @@ -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: diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java index 54228ca42ab47082c5aedf0dd0a14e5234a403a3..4ce5c121d89b24e6d35b0b6f7c734fd48ed3e0f4 100644 --- a/core/src/main/java/hudson/model/AbstractItem.java +++ b/core/src/main/java/hudson/model/AbstractItem.java @@ -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()); } /**