Opened 13 years ago
Last modified 5 months ago
#7614 reopened defect
preferences.xml: invalid XML character / reference to entity
Reported by: | anonymous | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | |
Keywords: | Cc: |
Description (last modified by )
If there is a (U+2642
) or &
in the preferences.xml, an error occures:
"Preferences file had errors.
Making backup of old one to /home/test/.josm/preferences.xml.bak and creating a new default preference file."
This are allowed characters in filenames (for example ext3 filesystem).
Example 1:
<list key='file-open.history'> <entry value='/test/Blabla/123.gpx'/> (...)
Repository Root: http://josm.openstreetmap.de/svn Build-Date: 2012-04-14 14:26:11 Last Changed Author: simon04 Revision: 5181 Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b URL: http://josm.openstreetmap.de/svn/trunk Last Changed Date: 2012-04-14 12:01:16 +0200 (Sat, 14 Apr 2012) Last Changed Rev: 5181 org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x{2}) was found in the value of attribute "{1}" and element is "1a". at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:391) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1391) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:944) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:436) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:253) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:741) at com.sun.org.apache.xerces.internal.jaxp.validation.StreamValidatorHelper.validate(StreamValidatorHelper.java:147) at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:116) at javax.xml.validation.Validator.validate(Validator.java:124) at org.openstreetmap.josm.data.Preferences.validateXML(Preferences.java:1476) at org.openstreetmap.josm.data.Preferences.load(Preferences.java:621) at org.openstreetmap.josm.data.Preferences.load(Preferences.java:583) at org.openstreetmap.josm.data.Preferences.init(Preferences.java:720) at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:194)
Example 2:
<list key='file-open.history'> <entry value='/test/Bla&bla/123.gpx'/> (...)
Repository Root: http://josm.openstreetmap.de/svn Build-Date: 2012-04-14 14:26:11 Last Changed Author: simon04 Revision: 5181 Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b URL: http://josm.openstreetmap.de/svn/trunk Last Changed Date: 2012-04-14 12:01:16 +0200 (Sat, 14 Apr 2012) Last Changed Rev: 5181 org.xml.sax.SAXParseException: The reference to entity "bla" must end with the ';' delimiter. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:391) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1391) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:845) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:436) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:253) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:741) at com.sun.org.apache.xerces.internal.jaxp.validation.StreamValidatorHelper.validate(StreamValidatorHelper.java:147) at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:116) at javax.xml.validation.Validator.validate(Validator.java:124) at org.openstreetmap.josm.data.Preferences.validateXML(Preferences.java:1476) at org.openstreetmap.josm.data.Preferences.load(Preferences.java:621) at org.openstreetmap.josm.data.Preferences.load(Preferences.java:583) at org.openstreetmap.josm.data.Preferences.init(Preferences.java:720) at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:194)
Attachments (2)
Change History (12)
comment:1 by , 13 years ago
Description: | modified (diff) |
---|
comment:2 by , 13 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
by , 13 years ago
Attachment: | bug_test.sh added |
---|
comment:3 by , 13 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
Ok, here is a real world example.
Create the test dir and test file (execute the attached bash script).
Then open the created test GPX-file, close JOSM.
You will find the following lines in preferences.xml:
<list key='file-open.history'> <entry value='/tmp/DIR
TEST/test.gpx'/>
Start JOSM, an error occures:
Preferences file had errors. Making backup of old one to /home/test/.josm/preferences.xml.bak and creating a new default preference file.
Now you can reproduce.
By the way:
HAL creates this funny mountpoints, if a USB mass storage device (GPS device or smartphone) sends a identifier, containing this characters.
Log:
Repository Root: http://josm.openstreetmap.de/svn Build-Date: 2012-04-14 14:26:11 Last Changed Author: simon04 Revision: 5181 Repository UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b URL: http://josm.openstreetmap.de/svn/trunk Last Changed Date: 2012-04-14 12:01:16 +0200 (Sat, 14 Apr 2012) Last Changed Rev: 5181 org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x{2}) was found in the value of attribute "{1}" and element is "1a". at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:391) at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1391) at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(XMLScanner.java:944) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanAttribute(XMLNSDocumentScannerImpl.java:436) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:253) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:741) at com.sun.org.apache.xerces.internal.jaxp.validation.StreamValidatorHelper.validate(StreamValidatorHelper.java:147) at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl.validate(ValidatorImpl.java:116) at javax.xml.validation.Validator.validate(Validator.java:124) at org.openstreetmap.josm.data.Preferences.validateXML(Preferences.java:1476) at org.openstreetmap.josm.data.Preferences.load(Preferences.java:621) at org.openstreetmap.josm.data.Preferences.load(Preferences.java:583) at org.openstreetmap.josm.data.Preferences.init(Preferences.java:720) at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:194)}}}
comment:4 by , 13 years ago
According to http://www.w3.org/TR/xml/#charsets, U+001A
is not a valid XML character. For that reason, Xerces refuses to parse this one – escaping as 
or 
does not help. Not sure how to fix this.
http://lists.xml.org/archives/xml-dev/201003/msg00080.html discusses the same issue. I think, we don't want to implement the work-around …
by , 13 years ago
Attachment: | 7614.patch added |
---|
comment:6 by , 13 years ago
I attached a possible fix. Avoids invalid XML file. In this case, the file entry in "Open Recent" does not exist.
follow-up: 9 comment:7 by , 13 years ago
#x1A is valid in XML 1.1: http://www.w3.org/TR/2006/REC-xml11-20060816/#charsets, but must be escaped as entity.
Not sure if XML 1.1 is supported by Java, changing the header in preferences.xml makes JOSM stall without any output.
comment:9 by , 11 years ago
Replying to bastiK:
Not sure if XML 1.1 is supported by Java.
It seems to be, at least there's a basic support. However, we also need XSD 1.1, which became a W3C recommendation in April 2012... I don't think we'll see it in Java SE before Java 9 at least.
I cannot reproduce: When saving
&.osm
from JOSM,<entry value='/tmp/&.osm'/>
is written to the preference file.U+2642
works, too.When editing the preference file by hand, make sure to correctly escape characters like
&
.