From: Artur Signell Date: Mon, 12 Sep 2016 20:39:19 +0000 (+0300) Subject: Handle encoded URL characters correctly when constructing widget set name (#20262) X-Git-Tag: 7.7.1~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4bc375d1d21f468e6433da3a183150e0bfe0cae4;p=vaadin-framework.git Handle encoded URL characters correctly when constructing widget set name (#20262) Change-Id: Idfdd5e6021444af5b08d48ddf90745b47ff4643d --- diff --git a/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java b/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java index b0d8cdd004..58e90f9268 100644 --- a/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java +++ b/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.Reader; +import java.net.URISyntaxException; import java.net.URL; import java.util.Collection; import java.util.HashSet; @@ -44,7 +45,8 @@ import java.util.regex.Pattern; */ public class WidgetSetBuilder { - public static void main(String[] args) throws IOException { + public static void main(String[] args) + throws IOException, URISyntaxException { if (args.length == 0) { printUsage(); } else { @@ -55,7 +57,7 @@ public class WidgetSetBuilder { } public static void updateWidgetSet(final String widgetset) - throws IOException, FileNotFoundException { + throws IOException, FileNotFoundException, URISyntaxException { boolean changed = false; Map availableWidgetSets = ClassPathExplorer @@ -69,9 +71,8 @@ public class WidgetSetBuilder { .getWidgetsetSourceDirectory(widgetsetFileName); } - String wsFullPath = sourceUrl.getFile() + "/" + widgetsetFileName; - - File widgetsetFile = new File(wsFullPath); + File widgetsetFile = new File(new File(sourceUrl.toURI()), + widgetsetFileName); if (!widgetsetFile.exists()) { // create empty gwt module file File parent = widgetsetFile.getParentFile(); @@ -138,7 +139,7 @@ public class WidgetSetBuilder { changed = changed || !content.equals(originalContent); if (changed) { - commitChanges(wsFullPath, content); + commitChanges(widgetsetFile, content); } } else { System.out @@ -154,10 +155,10 @@ public class WidgetSetBuilder { return content.replaceFirst("", ""); } - private static void commitChanges(String widgetsetfilename, String content) + private static void commitChanges(File widgetsetFile, String content) throws IOException { BufferedWriter bufferedWriter = new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(widgetsetfilename))); + new OutputStreamWriter(new FileOutputStream(widgetsetFile))); bufferedWriter.write(content); bufferedWriter.close(); }