diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-08 12:43:41 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-11-08 12:43:41 +0000 |
commit | 031a6876495a74326cd69b660333ab35450cf705 (patch) | |
tree | 9c224e3451fa06f4d8bfef932c5e06378afea109 /modules/simpletest | |
parent | 15d972d1618cf47852399f81ae5bb4010de85333 (diff) | |
download | brdo-031a6876495a74326cd69b660333ab35450cf705.tar.gz brdo-031a6876495a74326cd69b660333ab35450cf705.tar.bz2 |
#318636 by effulgentsia, sun, Damien Tournoud, Xano, and jrchamp: Make l() themable.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/common.test | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 483a671a0..d8bb13cc4 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -70,9 +70,23 @@ class CommonURLUnitTest extends DrupalUnitTestCase { * Confirm that invalid text given as $path is filtered. */ function testLXSS() { + global $conf; $text = $this->randomName(); $path = "<SCRIPT>alert('XSS')</SCRIPT>"; + // Regardless of whether there is a theme override of theme_link() or not, + // unless the 'theme_link' configuration variable is FALSE, l() will + // attempt to initialize the theme system in order to determine if + // the link needs to be themed. However, drupal_theme_initialize() requires + // a database query, which doesn't work in the context of unit tests, + // because simpletest sets up a table prefix, but doesn't generate the + // corresponding prefixed tables. We need to either circumvent theme system + // initialization, or make CommonURLUnitTest inherit from DrupalWebTestCase. + // Since our goal in this unit test is specifically to test the default + // implementation, we choose the former. + $theme_link_saved = isset($conf['theme_link']) ? $conf['theme_link'] : NULL; + $conf['theme_link'] = FALSE; $link = l($text, $path); + $conf['theme_link'] = $theme_link_saved; $sanitized_path = check_url(url($path)); $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, t('XSS attack @path was filtered', array('@path' => $path))); } |