Feature #12013
X-DOCUMENT:LOAD encoding and error handling compatibility
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:
0%
billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:
History
#1 Updated by Greg Shah 19 days ago
X-DOCUMENT:LOAD encoding and error handling compatibility¶
Project: Base Language
Problem¶
XDocumentImpl.load() (xml/XDocumentImpl.java, near line 754) supports the FILE, MEMPTR, LONGCHAR and URL source types, but its own comments record that it is not complete:
- the module header calls
load()"pretty badly broken"; - a TODO near line 756 notes that the error handling is not shared with the other X-DOCUMENT methods;
- a TODO near line 940 notes that "the I18N implications" are "probably WRONG!"
The concrete defect is in the LONGCHAR path. It converts the content to bytes with the JVM's platform default character set, then decodes those bytes with the encoding the XML declaration names. When the platform default differs from the declared encoding, or from the LONGCHAR's own codepage, non-ASCII characters are damaged.
Work¶
LONGCHARsource. Parse from the characters directly, without the byte round trip. Where the 4GL needs bytes, encode in theLONGCHAR's fixed codepage. Establish with testcases what OpenEdge does when theLONGCHAR's codepage and the XML declaration disagree, and match it.MEMPTRandFILEsources. Detect the encoding the way the 4GL does: byte order mark, then the XML declaration, then the default. Check a document with no declaration in a non-UTF-8 codepage.- Errors. Use one error path for an invalid source type, an unreadable source, and a document that is not well formed, matching the 4GL's message numbers and text. Cover the behaviour with and without
NO-ERROR, and the state of the X-DOCUMENT after a failed load. - Validation. Check the
validateargument andSCHEMA-LOCATION/ADD-SCHEMA-LOCATIONinteraction while in this code. - Correct the gap marking once done.
Testcases¶
Run against OpenEdge for the baseline:- UTF-8, ISO8859-1 and windows-1252 documents with non-ASCII content, loaded from
FILE,MEMPTRandLONGCHAR; - a
LONGCHARfixed to UTF-8 holding a document that declares ISO8859-1, and the reverse; - documents with and without a byte order mark and a declaration;
- malformed documents and missing files, with and without
NO-ERROR.