View Full Version : Module names cannot contain "&" characters

January 11th, 2011, 10:30
An oldie but goldie bug often found in XML-data programs seems to also manifest in Fantasy Grounds I'm sorry to say.

If you export a module, in my case "Abracadabra & an Arab Cadavar" then, well... firstly it's actually too long ! If you export with that name, you'll have no "open module" icon in your campaign, the long name just pushes if off the screen.

So, after a quick edit I created my module as "Abracadabra & an Arab". The exports the module fine, and within the definition.xml file I can see :

<?xml version="1.0" encoding="iso-8859-1"?>
<root version="2.07">
<name>Abracadabra &amp; An Arab</name>
<author>Ben Turner</author>

So I open my campaign, open up the module and start using the elements. No problem. Then I close the campaign, and later on reopen it... and the module has closed itself ! How rude...

Of course, the reason for this is within the campaign, the following has been saved into the modulestate.xml file :

<module name="Abracadabra & An Arab">
<loaded />
<disallow />

This is invalid XML - the & should be replaced by &amp. But not only that, the fact it's saved in this fashion means it does not find the module when the campaign is reopened.

One workaround would be to manually adjust the modulestate.xml file, but you need to do this every time - FGII overwrites this file with the invalid ampersand each time the campaign is saved.

So the only realistic workaround for now is one often employed with XML-data apps; stay clear of ampersands !!!

But whilst this is only a minor thing, it would I presume only be a minor fix, so worth flagging up.

January 11th, 2011, 12:23
this might be a minor problem, but I could swear it was a new problem.

previously I have used the &amp; in module titles and did not encounter this problem

I stopped using them however due to another (similar problem) - when you drag and drop an object from a library module with &amp; in the name and that object has a linked image in it (say a magic sword item with a link to a picture of the sword) it sets the shortcut for the picture to a module with & in its name making it imposible to open the image file.

I was sure Moon_wizard had listed this as fixed, but I have not tired it again.

I was thinking about changing the module activation window to give give more space or adding tool tips to give the full title on hover over, because I always seem to have modules with long names...

January 12th, 2011, 00:39
Sorcerer, unless I misunderstand phantomwhale, he didn't use &amp, he used the & itself. Since, as Moon_wizard admits, fg2 doesn't have any built-in xml-safe string handling (or at least sufficient implementation), fg2 rendered his title as was straight into xml, which formed an invalid xml file that wouldn't parse. Of course, I could be the one misunderstanding, and it surely woudn't be the last time I do that.

January 12th, 2011, 00:47
Yes, to confirm, I only ever typed (and saw) "&" into the FGII interface (which is as it should be).

It was only when rummaging through the backend XML files that I saw that FGII had failed to transform the module name to an XML-safe string when adding it to the modulestate.xml file, whereas it did apply an XML-safe string transformation when adding it to the definition.xml file.

It is this inconsistency that causes the problem (whatever FGII using to parse the modulestate.xml file does not complain about the invalid XML attribute, ior at least not in any way that is visible to me)