aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--netx/net/sourceforge/jnlp/util/XDesktopEntry.java22
2 files changed, 26 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c41f4fe..3fdd84d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-11-24 Omair Majid <[email protected]>
+ Fix PR592.
+ * netx/net/sourceforge/jnlp/util/XDesktopEntry.java
+ (getContentsAsReader): Sanitize information before adding to desktop file.
+ (sanitize): New method. Ensure that there are no newlines in input.
+
+2010-11-24 Omair Majid <[email protected]>
+
* netx/net/sourceforge/jnlp/resources/Messages.properties: Add
CVCertificateType.
* netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: Use
diff --git a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
index b4baef7..d5ebf0f 100644
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java
@@ -80,9 +80,9 @@ public class XDesktopEntry {
String fileContents = "[Desktop Entry]\n";
fileContents += "Version=1.0\n";
- fileContents += "Name=" + file.getTitle() + "\n";
+ fileContents += "Name=" + sanitize(file.getTitle()) + "\n";
fileContents += "GenericName=Java Web Start Application\n";
- fileContents += "Comment=" + file.getInformation().getDescription() + "\n";
+ fileContents += "Comment=" + sanitize(file.getInformation().getDescription()) + "\n";
fileContents += "Type=Application\n";
if (iconLocation != null) {
fileContents += "Icon=" + iconLocation + "\n";
@@ -91,7 +91,7 @@ public class XDesktopEntry {
}
if (file.getInformation().getVendor() != null) {
- fileContents += "Vendor=" + file.getInformation().getVendor() + "\n";
+ fileContents += "Vendor=" + sanitize(file.getInformation().getVendor()) + "\n";
}
//Shortcut executes the jnlp from cache and system preferred java..
@@ -102,6 +102,22 @@ public class XDesktopEntry {
}
/**
+ * Sanitizes a string so that it can be used safely in a key=value pair in a
+ * desktop entry file.
+ *
+ * @param input a String to sanitize
+ * @return a string safe to use as either the key or the value in the
+ * key=value pair in a desktop entry file
+ */
+ private static String sanitize(String input) {
+ if (input == null) {
+ return "";
+ }
+ /* key=value pairs must be a single line */
+ return input.split("\n")[0];
+ }
+
+ /**
* Get the size of the icon (in pixels) for the desktop shortcut
*/
public int getIconSize() {