I am currently debugging an issue that I found with the MediaFront module that turned out to be an issue with the drupal_to_js function. Basically what I am doing is attempting to replace PHP's json_encode function with the drupal_to_js function to make my module compatible with older versions of PHP ( less than version 5.2 ).

What I found out when I did this, though, is that I started to receive a "Parse Error" within the jQuery.ajax routine when attempting to send the node data to the jQuery media player. After further digging, I realized that the reason why jQuery is rejecting the json information is because it was adding a back slash to an apostrophe ( from the addslashes call ) within each string within the JSON structure. The problem with this, though, is that the strings are placed within double quotes ( where apostrophe's are allowed ). Apparently, the jQuery ajax routine does not like this and simply rejects the data.

I have fixed this issue and here is the patch to fix it. Basically, this override any backslash characters before an apostrophe added by the addslashes routine. This fix also now mimics PHP's json_encode routine when dealing with single quotes contained within double quoted strings.

Hope this makes it in. :)

Thanks,

Travis Tidwell.

CommentFileSizeAuthor
drupal_to_js.patch900 bytestravist

Comments

travist’s picture

Status: Active » Needs review
dooug’s picture

Status: Needs review » Closed (duplicate)