Skip to content

Commit

Permalink
[JENKINS-37026] Fix to encode URL to attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
miyajan committed Jul 28, 2016
1 parent 60e1f8f commit a6341ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -6,6 +6,8 @@
import hudson.tasks.test.TestObject;
import jenkins.model.Jenkins;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;

public class AttachmentTestAction extends TestAction {
Expand Down Expand Up @@ -60,4 +62,8 @@ public static boolean isImageFile(String filename) {
return filename.matches("(?i).+\\.(gif|jpe?g|png)$");
}

public static String getUrl(String filename) throws UnsupportedEncodingException {
return "attachments/" + URLEncoder.encode(filename, "UTF-8");
}

}
Expand Up @@ -13,7 +13,7 @@
<td class="pane">
<a class="${it.isImageFile(attachment) ? 'gallery' : ''}"
title="${attachment}"
href="attachments/${attachment}">${attachment}</a>
href="${it.getUrl(attachment)}">${attachment}</a>
</td>
</tr>
</j:forEach>
Expand Down

0 comments on commit a6341ac

Please sign in to comment.