2007-12-26 Complication
* Escape both CR, LF and CR LF line breaks in Router.saveConfig() and unescape them in DataHelper.loadProps() to support saving and loading config properties with line breaks * Change the update URLs textbox into a textarea like keys have, so different URLs go on different lines * Modify TrustedUpdate to provide a method which supplies a key list delimited with CR LF line breaks * Modify DEFAULT_UPDATE_URL to supply a default URL list delimited with CR LF line breaks * Modify selectUpdateURL() to handle URL lists delimited by any kind of line breaks * Start saving trusted update keys * Improve formatting on configupdate.jsp
This commit is contained in:
@ -92,7 +92,7 @@ jP69nPbh4KLGhF+SD0+0bW4=
|
||||
String propertyTrustedKeys = context.getProperty(PROP_TRUSTED_KEYS);
|
||||
|
||||
if ( (propertyTrustedKeys != null) && (propertyTrustedKeys.length() > 0) ) {
|
||||
StringTokenizer propertyTrustedKeysTokens = new StringTokenizer(propertyTrustedKeys, ",");
|
||||
StringTokenizer propertyTrustedKeysTokens = new StringTokenizer(propertyTrustedKeys, "\r\n");
|
||||
|
||||
while (propertyTrustedKeysTokens.hasMoreTokens())
|
||||
_trustedKeys.add(propertyTrustedKeysTokens.nextToken().trim());
|
||||
@ -100,6 +100,8 @@ jP69nPbh4KLGhF+SD0+0bW4=
|
||||
} else {
|
||||
_trustedKeys.add(DEFAULT_TRUSTED_KEY);
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("TrustedUpdate created, trusting " + _trustedKeys.size() + " keys.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,7 +276,26 @@ jP69nPbh4KLGhF+SD0+0bW4=
|
||||
public ArrayList getTrustedKeys() {
|
||||
return _trustedKeys;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetches the trusted keys for the current instance.
|
||||
*
|
||||
* @return A <code>String</code> containing the trusted keys,
|
||||
* delimited by CR LF line breaks.
|
||||
*/
|
||||
public String getTrustedKeysString() {
|
||||
StringBuffer buf = new StringBuffer(1024);
|
||||
for (int i = 0; i < _trustedKeys.size(); i++) {
|
||||
// If something already buffered, first add line break.
|
||||
if (buf.length() > 0) buf.append("\r\n");
|
||||
buf.append((String) _trustedKeys.get(i));
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the version string from a signed update file.
|
||||
*
|
||||
|
@ -236,6 +236,10 @@ public class DataHelper {
|
||||
if (split <= 0) continue;
|
||||
String key = line.substring(0, split);
|
||||
String val = line.substring(split+1);
|
||||
// Unescape line breaks after loading.
|
||||
// Remember: "\" needs escaping both for regex and string.
|
||||
val = val.replaceAll("\\\\r","\r");
|
||||
val = val.replaceAll("\\\\n","\n");
|
||||
if ( (key.length() > 0) && (val.length() > 0) )
|
||||
if (forceLowerCase)
|
||||
props.setProperty(key.toLowerCase(), val);
|
||||
|
Reference in New Issue
Block a user