From 60008bb4f0086f5048cc8969baf1613cecbbcdd6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 21 Jan 2022 08:04:23 -0800 Subject: [PATCH] GUACAMOLE-1511: Automatically trim whitespace from property values. --- .../properties/FileGuacamoleProperties.java | 3 ++- .../properties/PropertiesGuacamoleProperties.java | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/properties/FileGuacamoleProperties.java b/guacamole-ext/src/main/java/org/apache/guacamole/properties/FileGuacamoleProperties.java index 8be0b4e25..74d4e06d7 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/properties/FileGuacamoleProperties.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/properties/FileGuacamoleProperties.java @@ -29,7 +29,8 @@ import org.apache.guacamole.GuacamoleServerException; /** * GuacamoleProperties implementation which reads all properties from a - * standard Java properties file. + * standard Java properties file. Whitespace at the end of property values is + * automatically trimmed. */ public class FileGuacamoleProperties extends PropertiesGuacamoleProperties { diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/properties/PropertiesGuacamoleProperties.java b/guacamole-ext/src/main/java/org/apache/guacamole/properties/PropertiesGuacamoleProperties.java index 263f7ee3e..19afa8135 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/properties/PropertiesGuacamoleProperties.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/properties/PropertiesGuacamoleProperties.java @@ -24,7 +24,8 @@ import org.apache.guacamole.GuacamoleException; /** * GuacamoleProperties implementation which reads all properties from a - * {@link Properties} object. + * {@link Properties} object. Whitespace at the end of property values is + * automatically trimmed. */ public class PropertiesGuacamoleProperties implements GuacamoleProperties { @@ -43,12 +44,19 @@ public class PropertiesGuacamoleProperties implements GuacamoleProperties { * values exposed by this instance of PropertiesGuacamoleProperties. */ public PropertiesGuacamoleProperties(Properties properties) { - this.properties = properties; + this(properties); } + @Override public String getProperty(String name) throws GuacamoleException { - return properties.getProperty(name); + + String value = properties.getProperty(name); + if (value == null) + return null; + + return value.trim(); + } }