This is an automated email from the ASF dual-hosted git repository. svenmeier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 1db8b1c2778b435b51a84e1354dbb56475b23855 Author: Thorsten Schöning <[email protected]> AuthorDate: Sat Mar 14 17:11:33 2020 +0100 WICKET-6756 Avoid URL.getFile() Another place where "URL.getFile()" is forwarded to "FileOutputStream" without caring about proper decoding. --- .../org/apache/wicket/util/tester/DiffUtil.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/DiffUtil.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/DiffUtil.java index 309653e..68f129a 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/DiffUtil.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/DiffUtil.java @@ -18,10 +18,12 @@ package org.apache.wicket.util.tester; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; +import java.net.URISyntaxException; import java.net.URL; import org.apache.wicket.markup.MarkupParser; @@ -42,7 +44,7 @@ import org.slf4j.LoggerFactory; * <p> * Second: Create/replace the expected result file with the new content, if a system property has be * made available like -Dwicket.replace.expected.results=true - * + * * @author Juergen Donnerstag */ public final class DiffUtil @@ -52,7 +54,7 @@ public final class DiffUtil /** * Replace the expected result file with the current output. - * + * * @param document * How the expected result should look like * @param clazz @@ -68,9 +70,17 @@ public final class DiffUtil filename = filename.replace('.', '/'); filename += "/" + file; - final URL url = clazz.getClassLoader().getResource(filename); - filename = url.getFile(); - filename = filename.replaceAll("/target/test-classes/", "/src/test/java/"); + try + { + final URL url = clazz.getClassLoader().getResource(filename); + filename = new File(url.toURI()).getAbsolutePath(); + } + catch (URISyntaxException ex) + { + throw new IOException(ex); + } + + filename = filename.replaceAll("([/\\\\])target\\1test-classes\\1", "$1src$1test$1java$1"); PrintWriter out = new PrintWriter(new FileOutputStream(filename)); out.print(document); out.close(); @@ -79,7 +89,7 @@ public final class DiffUtil /** * Compare the output generated by Wicket ("document") with the a previously generated file * which contains the expected result. - * + * * @param document * Current output * @param file
