PDA

View Full Version : isformpost + isupload response back-slash question



mark.wharton
20 Jun 2010, 8:06 PM
Hello,

I'm working through the Ext.Direct spec to develop an Ext.Direct router and have a question about the isformpost + isupload response paragraph...

<html><body><textarea>{YOUR JSON RESPONSE HERE}</textarea></body></html>
&quot; must be back-slashed because the textarea will convert them to actual quotes. Therefore you must do a regular expression (/"/, "\"")

In my browser I see "&quot; must be back-slashed because the textarea will convert them to actual quotes" which makes sense (i.e. &quot; will become "). It's the next sentence "Therefore you must do a regular expression (/"/, "\"")" which has me confused. I don't see how that regular expression will do anything to address the &quot; issue.

Maybe it's just a browser character encoding/decoding/display issue. I have attached a screen shot in case the original text is lost in the post.

Thanks,

Mark

aconran
28 Jun 2010, 9:54 AM
Mark -

The issue is because the following HTML:

<textarea>
&quot;
</textarea>

Will be interpreted by the browser as:

<textarea>
"
</textarea>

Therefore executing some code like:

$json = preg_replace("/&quot;/", '\\&quot;', $json);

will escape the quotes generating:


<textarea>
\&quot;
</textarea>

mark.wharton
28 Jun 2010, 5:31 PM
Thanks for your response Aaron! That clears it up for me...

Actually when looking at the spec source (http://www.sencha.com/products/js/direct.php) the meaning is clear (I only just did that now) so it's a problem with browser rendering which should probably be fixed.

Cheers,

Mark