This is an automated email from the ASF dual-hosted git repository. svenmeier pushed a commit to branch wicket-8.x in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 9ac38d26a23f7c295d4610c65c907aab2b1e9cf9 Author: Thorsten Schöning <[email protected]> AuthorDate: Sat Mar 14 17:11:33 2020 +0100 WICKET-6757 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 1d8aa02..93288a7 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 @@ -16,10 +16,12 @@ */ package org.apache.wicket.util.tester; +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.junit.Assert; @@ -41,7 +43,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 @@ -51,7 +53,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 @@ -67,9 +69,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(); @@ -78,7 +88,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
