? real-clone.patch
? remove-drupal_to_js.patch
? sites/default/files
? sites/default/settings.php
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756
diff -u -p -r1.756 common.inc
--- includes/common.inc 30 Jan 2008 23:07:41 -0000 1.756
+++ includes/common.inc 16 Feb 2008 17:58:35 -0000
@@ -2063,7 +2063,7 @@ function drupal_get_js($scope = 'header'
switch ($type) {
case 'setting':
- $output .= '\n";
+ $output .= '\n";
break;
case 'inline':
foreach ($data as $info) {
@@ -2268,46 +2268,6 @@ function drupal_clear_js_cache() {
}
/**
- * Converts a PHP variable into its Javascript equivalent.
- *
- * We use HTML-safe strings, i.e. with <, > and & escaped.
- */
-function drupal_to_js($var) {
- switch (gettype($var)) {
- case 'boolean':
- return $var ? 'true' : 'false'; // Lowercase necessary!
- case 'integer':
- case 'double':
- return $var;
- case 'resource':
- case 'string':
- return '"'. str_replace(array("\r", "\n", "<", ">", "&"),
- array('\r', '\n', '\x3c', '\x3e', '\x26'),
- addslashes($var)) .'"';
- case 'array':
- // Arrays in JSON can't be associative. If the array is empty or if it
- // has sequential whole number keys starting with 0, it's not associative
- // so we can go ahead and convert it as an array.
- if (empty ($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
- $output = array();
- foreach ($var as $v) {
- $output[] = drupal_to_js($v);
- }
- return '[ '. implode(', ', $output) .' ]';
- }
- // Otherwise, fall through to convert the array as an object.
- case 'object':
- $output = array();
- foreach ($var as $k => $v) {
- $output[] = drupal_to_js(strval($k)) .': '. drupal_to_js($v);
- }
- return '{ '. implode(', ', $output) .' }';
- default:
- return 'null';
- }
-}
-
-/**
* Return data in JSON format.
*
* This function should be used for JavaScript callback functions returning
@@ -2321,7 +2281,7 @@ function drupal_json($var = NULL) {
drupal_set_header('Content-Type: text/javascript; charset=utf-8');
if (isset($var)) {
- echo drupal_to_js($var);
+ echo json_encode($var);
}
}
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.174
diff -u -p -r1.174 locale.inc
--- includes/locale.inc 9 Jan 2008 21:36:13 -0000 1.174
+++ includes/locale.inc 16 Feb 2008 17:58:35 -0000
@@ -2108,7 +2108,7 @@ function _locale_rebuild_js($langcode =
$data .= "'pluralFormula': function(\$n) { return Number({$language->formula}); }, ";
}
- $data .= "'strings': ". drupal_to_js($translations) ." };";
+ $data .= "'strings': ". json_encode($translations) ." };";
$data_hash = md5($data);
}
Index: modules/profile/profile.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v
retrieving revision 1.8
diff -u -p -r1.8 profile.admin.inc
--- modules/profile/profile.admin.inc 21 Jan 2008 15:20:43 -0000 1.8
+++ modules/profile/profile.admin.inc 16 Feb 2008 17:58:36 -0000
@@ -399,6 +399,6 @@ function profile_admin_settings_autocomp
while ($data = db_fetch_object($result)) {
$matches[$data->category] = check_plain($data->category);
}
- print drupal_to_js($matches);
+ drupal_json($matches);
exit();
}
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.63
diff -u -p -r1.63 system.admin.inc
--- modules/system/system.admin.inc 4 Feb 2008 12:35:48 -0000 1.63
+++ modules/system/system.admin.inc 16 Feb 2008 17:58:37 -0000
@@ -1619,8 +1619,8 @@ function system_date_time_settings_submi
*/
function system_date_time_lookup() {
$result = format_date(time(), 'custom', $_GET['format']);
- echo drupal_to_js($result);
- exit;
+ drupal_json($result);
+ exit();
}
/**
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.198
diff -u -p -r1.198 upload.module
--- modules/upload/upload.module 12 Feb 2008 13:49:01 -0000 1.198
+++ modules/upload/upload.module 16 Feb 2008 17:58:37 -0000
@@ -630,6 +630,6 @@ function upload_js() {
// We send the updated file attachments form.
// Don't call drupal_json(). ahah.js uses an iframe and
// the header output by drupal_json() causes problems in some browsers.
- print drupal_to_js(array('status' => TRUE, 'data' => $output));
+ print json_encode(array('status' => TRUE, 'data' => $output));
exit;
}