Skip to content
Permalink
Browse files
Merge pull request #16 from miyajan/JENKINS-37026
[JENKINS-37026] Fix to encode URL to attachments
  • Loading branch information
jglick committed Feb 22, 2018
2 parents 5914e4a + a6341ac commit 579bba59885f38ba85a0bb571037cd1bed188f1d
@@ -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 {
@@ -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");
}

}
@@ -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>

0 comments on commit 579bba5

Please sign in to comment.