diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-09 23:36:55 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-01-09 23:36:55 +0000 |
commit | 92efec6e1e23512e37bab2a6a3e0f979324f1e11 (patch) | |
tree | 2fdcc7e3357dd0f37c9e0032b26b8d47229973e7 /modules/simpletest/tests/common.test | |
parent | 059d9eb62589d5bf6585c6a991e07b6fc8df544b (diff) | |
download | brdo-92efec6e1e23512e37bab2a6a3e0f979324f1e11.tar.gz brdo-92efec6e1e23512e37bab2a6a3e0f979324f1e11.tar.bz2 |
#479368 by Heine and asimmonds: Fixed drupal_to_js() provides bad unicode conversions.
Diffstat (limited to 'modules/simpletest/tests/common.test')
-rw-r--r-- | modules/simpletest/tests/common.test | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 156bb8fd8..6c617edf7 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -1802,6 +1802,7 @@ class DrupalJSONTest extends DrupalUnitTestCase { } // Characters that must be escaped. $html_unsafe = array('<', '>', '&'); + $html_unsafe_escaped = array('\u003c', '\u003e', '\u0026'); // Verify there aren't character encoding problems with the source string. $this->assertIdentical(strlen($str), 128, t('A string with the full ASCII table has the correct length.')); @@ -1824,6 +1825,10 @@ class DrupalJSONTest extends DrupalUnitTestCase { foreach ($html_unsafe as $char) { $this->assertTrue(strpos($json, $char) === FALSE, t('A JSON encoded string does not contain @s.', array('@s' => $char))); } + // Verify that JSON encoding escapes the HTML unsafe characters + foreach ($html_unsafe_escaped as $char) { + $this->assertTrue(strpos($json, $char) > 0, t('A JSON encoded string contains @s.', array('@s' => $char))); + } $json_decoded = drupal_json_decode($json); $this->assertNotIdentical($source, $json, t('An array encoded in JSON is not identical to the source.')); $this->assertIdentical($source, $json_decoded, t('Encoding structured data to JSON and decoding back results in the original data.')); |