From e49ac650a665ed864a9343dc5a97b5ae465cc744 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 3 Jul 2009 19:21:55 +0000 Subject: - Patch #310139 by pwolanin, c960657: drupal_query_string_encode() should not call drupal_urlencode(). --- modules/simpletest/tests/common.test | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'modules/simpletest/tests') diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 7c0455952..d4a07be73 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -8,8 +8,8 @@ class CommonLUnitTest extends DrupalUnitTestCase { public static function getInfo() { return array( - 'name' => t('Tests for the l() function'), - 'description' => t('Confirm that url() works correctly with various input.'), + 'name' => t('URL generation tests'), + 'description' => t('Confirm that url(), drupal_query_string_encode(), and l() work correctly with various input.'), 'group' => t('System'), ); } @@ -22,8 +22,18 @@ class CommonLUnitTest extends DrupalUnitTestCase { $path = ""; $link = l($text, $path); $sanitized_path = check_url(url($path)); - $this->assertTrue(strpos($link, $sanitized_path) != FALSE, t('XSS attack @path was filtered', array('@path' => $path))); + $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, t('XSS attack @path was filtered', array('@path' => $path))); } + + /** + * Test drupal_query_string_encode(). + */ + function testDrupalQueryStringEncode() { + $this->assertEqual(drupal_query_string_encode(array('a' => ' &#//+%20@۞')), 'a=%20%26%23%2F%2F%2B%2520%40%DB%9E', t('Value was properly encoded.')); + $this->assertEqual(drupal_query_string_encode(array(' &#//+%20@۞' => 'a')), '%20%26%23%2F%2F%2B%2520%40%DB%9E=a', t('Key was properly encoded.')); + $this->assertEqual(drupal_query_string_encode(array('a' => '1', 'b' => '2', 'c' => '3'), array('b')), 'a=1&c=3', t('Value was properly excluded.')); + $this->assertEqual(drupal_query_string_encode(array('a' => array('b' => '2', 'c' => '3')), array('b', 'a[c]')), 'a[b]=2', t('Nested array was properly encoded.')); + } } class CommonSizeTestCase extends DrupalUnitTestCase { -- cgit v1.2.3