GUACAMOLE-1511: Automatically trim whitespace from property values.

This commit is contained in:
Michael Jumper
2022-01-21 08:04:23 -08:00
parent 1b3361e006
commit 60008bb4f0
2 changed files with 13 additions and 4 deletions

View File

@@ -29,7 +29,8 @@ import org.apache.guacamole.GuacamoleServerException;
/** /**
* GuacamoleProperties implementation which reads all properties from a * 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 { public class FileGuacamoleProperties extends PropertiesGuacamoleProperties {

View File

@@ -24,7 +24,8 @@ import org.apache.guacamole.GuacamoleException;
/** /**
* GuacamoleProperties implementation which reads all properties from a * 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 { public class PropertiesGuacamoleProperties implements GuacamoleProperties {
@@ -43,12 +44,19 @@ public class PropertiesGuacamoleProperties implements GuacamoleProperties {
* values exposed by this instance of PropertiesGuacamoleProperties. * values exposed by this instance of PropertiesGuacamoleProperties.
*/ */
public PropertiesGuacamoleProperties(Properties properties) { public PropertiesGuacamoleProperties(Properties properties) {
this.properties = properties; this(properties);
} }
@Override @Override
public String getProperty(String name) throws GuacamoleException { public String getProperty(String name) throws GuacamoleException {
return properties.getProperty(name);
String value = properties.getProperty(name);
if (value == null)
return null;
return value.trim();
} }
} }