D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4509 - XML parser in std.xml throws TagException if the attr value is put in apostrophes.
Summary: XML parser in std.xml throws TagException if the attr value is put in apostro...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Linux
: P2 major
Assignee: Abhishek Kumar
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2010-07-26 10:24 UTC by Piotr Mitana
Modified: 2016-10-01 11:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Piotr Mitana 2010-07-26 10:24:43 UTC
The best way to illustrate this error is this code:

[code]
import std.xml;

void main()
{
	string goesRight = `<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="jid.pl" id="587a5767" xml:lang="en" version="1.0"></stream:stream>`;
	string goesWrong = `<?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='jid.pl' id='587a5767' xml:lang='en' version='1.0'></stream:stream>`;
	
	DocumentParser parser = new DocumentParser(goesRight);
}
[/code]

It creates a DocumentParser object and shuts down. But when change the constructor argument to goesWrong (the only difference between the two strings are " changed to '. Please note that in the prologue it doesn't matter), it results in TagError.
Comment 1 Infiltrator 2015-10-31 14:36:10 UTC
Still exists in 2.068.

Backtrace (lacking line numbers, sadly):

std.xml.TagException@std/xml.d(2743): <stream:stream xmlns:stream=
----------------
./test(void std.xml.ElementParser.parse()+0x2ba) [0x809910a]
./test(std.xml.DocumentParser std.xml.DocumentParser.__ctor(immutable(char)[])+0x33) [0x8098d33]
./test(_Dmain+0x38) [0x80935b8]
./test(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv+0x12) [0x8094d82]
./test(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x18) [0x8094cf0]
./test(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()+0x27) [0x8094d47]
./test(void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate())+0x18) [0x8094cf0]
./test(_d_run_main+0x166) [0x8094c86]
./test(main+0x14) [0x8093634]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xf3) [0xb75b4a63]
Comment 2 Abhishek Kumar 2016-03-08 06:59:54 UTC
I have sent a PR to fix this bug https://github.com/D-Programming-Language/phobos/pull/4064 .
Comment 3 github-bugzilla 2016-07-06 22:35:52 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/1533801fc890ee70178f04059422e9ce0e41d239
std.xml: accept single quotes for attributes

Fixes issue 4509 - XML parser in std.xml throws TagException if the
attr value is put in apostrophes.

https://github.com/dlang/phobos/commit/d231d783e68ed8b3c3950158a6ccc696b9be33b8
Merge pull request #4567 from aG0aep6G/4509

Fix issue 4509 - XML parser in std.xml throws TagException if the attr value is put in apostrophes.
Comment 4 github-bugzilla 2016-10-01 11:46:10 UTC
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/1533801fc890ee70178f04059422e9ce0e41d239
std.xml: accept single quotes for attributes

https://github.com/dlang/phobos/commit/d231d783e68ed8b3c3950158a6ccc696b9be33b8
Merge pull request #4567 from aG0aep6G/4509