dbankier / XMLTools-For-Appcelerator-Titanium

MIT License
64 stars 12 forks source link

Malloc error with .toJSON(); #8

Open CreativeKaizen opened 9 years ago

CreativeKaizen commented 9 years ago

During tests on iOS I got stuck with some XML string (http://rdlpzg.gis-net.pl/geoserver-zg/wms/?request=GetCapabilities&service=WMS).

Creating an object works fine:

//responseText is AJAX response from Ti.Network.HTTPClien var xml = new XMLTools(this.responseText);

but using .toJSON():

xml.toJSON();

casue malloc (memory allocation) error and freezes the app.

If there is no good way to work with long XMLs then there should be some safety gauge which would prevent occuring such error (try/catch doesn't work in this case).

Regards and thanks for great work.

dbankier commented 9 years ago

That's a big file and might be a little hard to debug. The library uses recursion in JS, so size might be the issue. Can you debug the library and see where it crashes.

CreativeKaizen commented 9 years ago

Hi,

Thanks for quick answer.

The problem is not with the file. Other (online) libraries can manage that file. Library you use (http://www.thomasfrank.se/xml_to_json.html) gets error here:

SyntaxError: identifier starts immediately after numeric literal

....service.onlineresource.xmlns%3axlink=unescape('http%3A//www.w3.org/1999/xlink'

line 79: eval() function;

I suppose recursion goes into infinite loop and that's the reason of malloc error.

dbankier commented 9 years ago

Not sure. As an FYI, XMLTools doesn't use that the library, only follows its syntax.