Page 1 of 1

[Solved] "Well-formed" ManiaCode question: install_map

Posted: 08 Apr 2017, 15:44
by ChallengeSY
While adding functionality to my little map repository, I add in functionality to automatically download a map. Upon testing the download button, I receive this:
Error Report wrote: Cannot retrieve the Manialink:
ManiaCode script is not well-formed
Here is the XML file that is generated by the PHP script, as captured by Fiddler:

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>

<maniacode>
<install_map>
  <url>https://sm.mania-exchange.com/maps/download/13937</url>
</install_map>
</maniacode>
While looking through various guides, I have seen conflicting sources as to whether the name tag inside install_map is required or not. Which source is most accurate? Is there anything else I might be missing?

Re: "Well-formed" ManiaCode question(s)

Posted: 08 Apr 2017, 16:09
by undef.de
You should replace the common entities in the URL (even if they are not included in your example yet):

Code: Select all

	public function encodeEntities ($string) {
		return str_replace(
				array(
					'&',
					'"',
					"'",
					'>',
					'<',
				),
				array(
					'&amp;',
					'&quot;',
					'&apos;',
					'&gt;',
					'&lt;',
				),
				$string
		);
	}
Taken from my UASECO helper.class.

That's the only thing that i can imagine right now.

Re: "Well-formed" ManiaCode question(s)

Posted: 08 Apr 2017, 17:04
by ChallengeSY
It will definitely help later on, but I still wonder how this ManiaCode managed to fail the well-formed test, when XML validators by W3Schools and W3C report zero errors. It is one thing if it is not well formed, but it is a different matter if it is well formed, but invalid.

On a somewhat related note, the safety mechanism works fine if someone tries to execute the codename without having a map ID in session memory. No errors are triggered, and the message is properly shown.

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>

<maniacode>
<show_message>
  <message>No map ID was successfully supplied</message>
</show_message>
</maniacode>

Re: "Well-formed" ManiaCode question(s)

Posted: 08 Apr 2017, 17:08
by zocka
Based on the maniaplanet wiki regarding maniacodes, the implementation in Nadeo's manialib and the implementation in steeffeen's FML I would say that the name is required.
I think the name part was displayed in the dialog as "downloading <name>".

As far as I know nothing much changed for maniacodes in the last years, so I usually look up that wiki link, but I haven't used maniacodes for quite some years.

Re: "Well-formed" ManiaCode question(s)

Posted: 08 Apr 2017, 17:24
by ChallengeSY
Now, it makes sense. The name tag is required, otherwise the XML file is invalid. Fortunately, the file name and map name are preserved even if I have to deviate from the them. In fact, it looks pretty good testing out the downloads.

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>

<maniacode>
<install_map>
  <name>Gentle Terrace</name>
  <url>https://sm.mania-exchange.com/maps/download/13937</url>
</install_map>
</maniacode>