diff options
Diffstat (limited to 'gnu/java/util/prefs/GConfBasedPreferences.java')
-rw-r--r-- | gnu/java/util/prefs/GConfBasedPreferences.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/gnu/java/util/prefs/GConfBasedPreferences.java b/gnu/java/util/prefs/GConfBasedPreferences.java index 5702751cf..a7e2322b5 100644 --- a/gnu/java/util/prefs/GConfBasedPreferences.java +++ b/gnu/java/util/prefs/GConfBasedPreferences.java @@ -72,7 +72,6 @@ import java.util.prefs.BackingStoreException; * <br /> * * @author Mario Torre <neugens@limasoftware.net> - * @version 1.0.1 */ public class GConfBasedPreferences extends AbstractPreferences @@ -136,12 +135,20 @@ public class GConfBasedPreferences absolutePath = absolutePath.substring(0, absolutePath.length() - 1); } + // strip invalid characters + // please, note that all names are unescaped into the native peer + int index = absolutePath.lastIndexOf('/'); + if (index > -1) + { + absolutePath = absolutePath.substring(0, index + 1); + absolutePath = absolutePath + GConfNativePeer.escapeString(name); + } + this.node = this.getRealRoot(isUser) + absolutePath; boolean nodeExist = backend.nodeExist(this.node); this.newNode = !nodeExist; - backend.startWatchingNode(this.node); } /** @@ -156,7 +163,15 @@ public class GConfBasedPreferences // we don't check anything here, if the node is a new node this will be // detected in the constructor, so we simply return a new reference to // the requested node. - return new GConfBasedPreferences(this, name, this.isUser); + + GConfBasedPreferences preferenceNode + = new GConfBasedPreferences(this, name, this.isUser); + + // register the node for to GConf so that it can listen + // events outside the scope of the application + backend.startWatchingNode(this.node); + + return preferenceNode; } /** @@ -365,6 +380,10 @@ public class GConfBasedPreferences { String nodeName = ""; + // strip key + // please, note that all names are unescaped into the native peer + key = GConfNativePeer.escapeString(key); + if (this.node.endsWith("/")) { nodeName = this.node + key; @@ -373,7 +392,7 @@ public class GConfBasedPreferences { nodeName = this.node + "/" + key; } - + return nodeName; } |