alter drupal_to_js() to use json_encode()

pwolanin - February 16, 2008 - 18:08
Project:Drupal
Version:7.x-dev
Component:javascript
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

Since we require PHP 5.2, we can rely instead on the built-in function json_encode()

http://www.php.net/manual/en/function.json-encode.php

Someone who knows more about the AHAH functionality should look at this- - also this change seem to break upload module's attach button, which suggests that there is some difference between the output of drupal_to_js() and json_encode()

AttachmentSize
remove-drupal_to_js.patch5.19 KB

#1

pwolanin - February 16, 2008 - 18:41
Status:needs review» needs work

Ahh - investigation reveals that json_encode() does not escape < > or & the way drupal_to_js() does - thus there are HTML errors when the AHAH tries to get the updated form.

#2

pwolanin - February 16, 2008 - 18:48
Title:remove drupal_to_js()» alter drupal_to_js() to use json_encode()
Status:needs work» needs review

new patch - leave drupal_to_js() so we can escape to HTML-safe, but use the built-in json_encode() for efficiency.

With this the upload form AHAH, at least, seems to work right.

AttachmentSize
improve-drupal_to_js-222578-2.patch 1.82 KB

#3

Wim Leers - February 16, 2008 - 20:29

Subscribing. Looking good! :)

#4

pwolanin - February 24, 2008 - 22:51

tested with PHP 5.2.4, Mac 10.4, FF 2.0 and Safari 3.0, apache 1.3:

book, upload, poll module AHA all works fine, user autocomplete field in node form works fine.

#5

joshk - February 24, 2008 - 23:07
Status:needs review» reviewed & tested by the community

Tested also in ie6 and ie7. Poll, book, upload and autocomplete all work.

#6

Dries - March 17, 2008 - 17:01
Status:reviewed & tested by the community» fixed

I committed this to CVS HEAD. Thanks.

#7

kkaefer - March 18, 2008 - 04:51
Status:fixed» active

Note: I asked Steven about why he introduced the escaping in the first place, since everything seems to work fine without. The reason he put that into place is because it was required for the upload.module's iframe mechanism. This however, has been removed (and replaced with AHAH). That means, that we can get rid of the encoding after we tested that everything still works.

#8

pwolanin - March 18, 2008 - 12:24

@kk - during my testing it did NOT work when the escaping was removed. See the first patch.

#9

pwolanin - March 20, 2008 - 22:10
Status:active» fixed

back to fixed

#10

Anonymous (not verified) - April 3, 2008 - 22:13
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.