Skip to content

Commit

Permalink
Merge pull request #16 from miyajan/JENKINS-37026
Browse files Browse the repository at this point in the history
[JENKINS-37026] Fix to encode URL to attachments
  • Loading branch information
jglick committed Feb 22, 2018
2 parents 5914e4a + a6341ac commit 579bba5
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 579bba5

Please sign in to comment.