PDA

View Full Version : bug: Fiddle does not escape quotes in XML data



Matt_A
27 Jul 2016, 2:01 AM
It appears that Fiddle cannot cope when XML in a mock data file contains single quotes (possibly only when it's a mix of single and double, but not checked).

It is simply taking the content of the XML file and placing it into a string 'data' property, surrounding it with single quotes. If there is a single quote within the XML string then it invalidates the Javascript resulting in a 'unresolved identifier doFiddleStuff()' console error.

If possible, it would be nice if the code that moved the XML into the property would also escape any illegal characters. I imagine it will have a similar issue with JSON, but I've not tried.

Gary Schlosberg
27 Jul 2016, 4:42 AM
Thanks for the report. Are we talking about poorly formed XML (unmatched single quote) or a single quote which is part of the data within double quotes?

mitchellsimoens
27 Jul 2016, 4:53 AM
Fiddle 2 will not work the same as the current fiddle and isn't far off from being deployed to a testing environment so this will not be worked on for the current fiddle. You'll have to do the escaping in your fiddle I'm afraid.

Matt_A
27 Jul 2016, 5:10 AM
Neither, the text is a single quote in an element (i.e.
<example>Mark's</example>)

This will end up in the run.js as something like


data : '<example>Mark's</example>'

and the extra ' breaks the javascript.

That's fine about it not being included until next release, I just thought I'd raise it in case it was an unknown issue

mitchellsimoens
27 Jul 2016, 5:12 AM
Sure and appreciate it. Fiddle 1 used framework overrides to simulate data responses so it's purely all in the browser. Fiddle 2 will use real network requests so there isn't any string within a string. Can I have your fiddle ID that is failing just so I can test under Fiddle 2 to make sure this is actually working?

Matt_A
27 Jul 2016, 5:27 AM
Hopefully you can see this: https://fiddle.sencha.com/#fiddle/1ea1 The actual code itself isn't working at the moment (I'm trying to load XML into nested models), but the quote in the XML breaks the doFiddleStuff call. When it's removed the code runs and gets to the failure call.