Bug 3201 – std.xml incorrectly converts symbols in attributes, & -> &amp
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-07-21T18:05:00Z
Last change time
2015-06-09T01:28:07Z
Keywords
patch
Assigned to
andrei
Creator
Jesse.K.Phillips+D
Comments
Comment #0 by Jesse.K.Phillips+D — 2009-07-21T18:05:17Z
The example code below will output:
Attr: What & Up
Elem: What & Up
Expected:
Attr: What & Up
Elem: What & Up
*testfile.xml:*
<?xml version="1.0" encoding="utf-8"?> <Tests>
<Test thing="What & Up">What & Up</Test>
</Tests>
*test.d:*
import std.stdio;
import std.xml;
void main() {
auto file = "testfile.xml";
auto s = cast(string)std.file.read(file);
auto xml = new DocumentParser(s);
xml.onStartTag["Test"] = (ElementParser xml) {
writeln("Attr: ", xml.tag.attr["thing"]);
};
xml.onEndTag["Test"] = (in Element e) {
writeln("Elem: ", e.text);
};
xml.parse();
}
Comment #1 by dfj1esp02 — 2009-07-27T02:50:24Z
I found it in bug 2979: for some reason encode function is used to unescape attribute value.
Comment #2 by r.sagitario — 2010-04-05T10:03:14Z
As the test case was the same in #3200, I've attached the patch that fixes both there