8213162: Association description in Inno Setup cannot contain double quotes JDK-8200758-branch
authorherrick
Wed, 31 Oct 2018 19:02:03 -0400
branchJDK-8200758-branch
changeset 57011 7df1e4bf870a
parent 56999 b50d414a755c
child 57012 200666876601
8213162: Association description in Inno Setup cannot contain double quotes Reviewed-by: almatvee
src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinExeBundler.java
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinExeBundler.java	Tue Oct 23 09:05:37 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinExeBundler.java	Wed Oct 31 19:02:03 2018 -0400
@@ -727,7 +727,7 @@
                     .append(entryName)
                     .append(
                     "\"; ValueType: string; ValueName: \"\"; ValueData: \"")
-                    .append(description)
+                    .append(removeQuotes(description))
                     .append("\"; Flags: uninsdeletekey\r\n");
             } else {
                 registryEntries.append(
@@ -735,7 +735,7 @@
                     .append(entryName)
                     .append(
                     "\"; ValueType: string; ValueName: \"\"; ValueData: \"")
-                    .append(description)
+                    .append(removeQuotes(description))
                     .append("\"; Flags: uninsdeletekey\r\n");
             }
 
@@ -811,6 +811,16 @@
         return true;
     }
 
+    private final static String removeQuotes(String s) {
+        if (s.length() > 2 && s.startsWith("\"") && s.endsWith("\"")) {
+            // special case for '"XXX"' return 'XXX' not '-XXX-'
+            // note '"' and '""' are excluded from this special case
+            s = s.substring(1, s.length() - 1);
+        }
+        // if there interior double quotes replace them with '-'
+        return s.replaceAll("\"", "-");
+    }
+        
     private final static String DEFAULT_INNO_SETUP_ICON =
             "icon_inno_setup.bmp";