[9] RFC JDK-8068373: (prefs) FileSystemPreferences writes \0 to XML storage, causing loss of all preferences

Paul Sandoz paul.sandoz at oracle.com
Thu Feb 12 16:18:47 UTC 2015


On Feb 12, 2015, at 4:37 PM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:

> Hi Paul,
> 
> On Feb 12, 2015, at 4:37 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
> 
>> What do existing XML APIs do?
> 
> This is a morass and I hope that someone more apt to know it well would comment. The U+0000 null control character is always illegal though I do know that.

Yes. IIRC XML 1.1 basically allows any character except U+0000.


> 
>> My guess from looking at your webrev APIs such as DOM allow such invalid characters when writing and reading? If so that would seem to be more of a fundamental issue with those APIs and not specifically with preferences.
> 
> I tend to agree where the DOM does allow the characters: they should be handled.
> 
>> I think there should be an error if a key or value contains a the U+0000 character when writing out the set of property entries to XML, otherwise it just propagates the error to who or what is consuming that XML file.
> 
> The problem is that on OSX and Windows prefs are not stored to XML

What are they stored in? name/value pairs?


> whereas on Unix they are.

Is that a specification requirement?


> That would make it an error to add such a value to the prefs on some platforms but not on others.
> 

Yes, for an interoperable format potentially read by other tools having U+0000 is a really bad idea.

My inclination is if properties are written out to a text file then it should fail if a key/value contains U+0000 (Binary data should be base64 encoded in such cases.) Replacing just subtlety hides or defers the issue.

Paul.



More information about the core-libs-dev mailing list