src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java
Print this page
rev 11736 : 8075156: (prefs) remove() should disallow the use of the null control character '\u0000' as key
Summary: Extend disallowing null control character key to remove()
Reviewed-by: XXX
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -47,17 +47,10 @@
* @see Preferences
* @since 1.4
*/
class FileSystemPreferences extends AbstractPreferences {
- /**
- * The code point U+0000, assigned to the null control character, is the
- * only character encoded in Unicode and ISO/IEC 10646 that is always
- * invalid in any XML 1.0 and 1.1 document.
- */
- private static final String CODE_POINT_U0000 = String.valueOf('\u0000');
-
static {
PrivilegedAction<Void> load = () -> {
System.loadLibrary("prefs");
return null;
};
@@ -530,15 +523,10 @@
public boolean isUserNode() {
return isUserNode;
}
protected void putSpi(String key, String value) {
- if (key.indexOf(CODE_POINT_U0000) != -1) {
- throw new IllegalArgumentException("Key contains code point U+0000");
- } else if (value.indexOf(CODE_POINT_U0000) != -1) {
- throw new IllegalArgumentException("Value contains code point U+0000");
- }
initCacheIfNecessary();
changeLog.add(new Put(key, value));
prefsCache.put(key, value);
}