Page 1 of 1
(New?) (Replay) XML headers do not escape special characters
Posted: 14 Jul 2013, 11:02
by TGYoshi
This image shows the XML header chunk of a replay:
The & symbol isn't escaped at all. As a result, "normal" XML parsing fails.
Re: (New?) (Replay) XML headers do not escape special charac
Posted: 14 Jul 2013, 11:16
by Xymph
That's a long-standing issue. That's why the XML parsing in my GBX Data Fetcher module escapes them beforehand:
Code: Select all
protected function parseXMLstring()
{
[...]
// escape '&' characters unless already a known entity
$xml = preg_replace('/&(?!(?:amp|quot|apos|lt|gt);)/', '&', $this->xml);
[...]
}
Re: (New?) (Replay) XML headers do not escape special charac
Posted: 14 Jul 2013, 12:36
by TGYoshi
Well, that's just stupid then

.
I suspect (or hope) < and > are escaped properly, so why not make sure & is escaped as well?
Re: (New?) (Replay) XML headers do not escape special charac
Posted: 14 Jul 2013, 13:21
by The_Big_Boo
TGYoshi wrote:I suspect (or hope) < and > are escaped properly, so why not make sure & is escaped as well?
They're actually not as you can notice in Xymph's regex (lt and gt are respectively < and >)
Re: (New?) (Replay) XML headers do not escape special charac
Posted: 14 Jul 2013, 13:54
by TGYoshi
The_Big_Boo wrote:TGYoshi wrote:I suspect (or hope) < and > are escaped properly, so why not make sure & is escaped as well?
They're actually not as you can notice in Xymph's regex (lt and gt are respectively < and >)
Doesn't it search for & without a lt/gt/.. behind it, then replace it?
So I suspect < and > is escaped, but & isn't for some stupid reason.
Re: (New?) (Replay) XML headers do not escape special charac
Posted: 14 Jul 2013, 14:57
by Slig
TGYoshi wrote:So I suspect < and > is escaped, but & isn't for some stupid reason.
Yes. The problem is that of course we can expect it to be corrected one day, but anyway to support existing replays you are anyway forced to handle it like it is actually (and so don't really care if it is corrected or not)

Re: (New?) (Replay) XML headers do not escape special charac
Posted: 15 Jul 2013, 12:31
by TGYoshi
The map's name got & escaped properly. zzz
Thanks for the regex anyway, that will probably be the 'solution' for this

.
Re: (New?) (Replay) XML headers do not escape special charac
Posted: 15 Jul 2013, 22:08
by Xymph
Yes, special chars are properly escaped in other fields of the XML header, but not in all fields - like the zone. So the regex covers both situations indeed.