(New?) (Replay) XML headers do not escape special characters

Moderator: NADEO

Locked
User avatar
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

(New?) (Replay) XML headers do not escape special characters

Post by TGYoshi »

This image shows the XML header chunk of a replay:
Image

The & symbol isn't escaped at all. As a result, "normal" XML parsing fails.
=3
User avatar
Xymph
Posts: 1399
Joined: 15 Jun 2010, 20:35
Contact:

Re: (New?) (Replay) XML headers do not escape special charac

Post 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);
[...]
  }
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
User avatar
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

Re: (New?) (Replay) XML headers do not escape special charac

Post by TGYoshi »

Well, that's just stupid then :roflol: .

I suspect (or hope) < and > are escaped properly, so why not make sure & is escaped as well?
=3
The_Big_Boo
Posts: 1026
Joined: 15 Jun 2010, 15:46

Re: (New?) (Replay) XML headers do not escape special charac

Post 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 >)
OS: Win 7 Pro x64
RAM: 2x4GB Corsair @ 1600MHz
CPU: Intel i5 760 @ 3.6GHz
Mobo: Asus P7P55D-E
GPU: NVidia GTX 760 2GB
HDD: WD Black 1TB
Sound: VIA VT1828S (onboard)
Peripherals: Razer DeathAdder - Razer DeathStalker - Logitech F310
User avatar
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

Re: (New?) (Replay) XML headers do not escape special charac

Post 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.
=3
User avatar
Slig
Posts: 637
Joined: 15 Jun 2010, 11:52
Location: TraXicoLand

Re: (New?) (Replay) XML headers do not escape special charac

Post 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) ;)
User avatar
TGYoshi
Posts: 795
Joined: 15 Mar 2011, 16:59

Re: (New?) (Replay) XML headers do not escape special charac

Post by TGYoshi »

The map's name got & escaped properly. zzz

Thanks for the regex anyway, that will probably be the 'solution' for this :P.
=3
User avatar
Xymph
Posts: 1399
Joined: 15 Jun 2010, 20:35
Contact:

Re: (New?) (Replay) XML headers do not escape special charac

Post 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.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub
Locked

Return to “Maniaplanet Reports”

Who is online

Users browsing this forum: No registered users and 0 guests