Issue #3310081 by mcdruid: javascript links in contrib broken since 7.92
parent
3c7c72fbcd
commit
9a82e007b0
|
@ -2608,7 +2608,14 @@ function l($text, $path, array $options = array()) {
|
|||
$use_theme = FALSE;
|
||||
}
|
||||
}
|
||||
$path = drupal_strip_dangerous_protocols((string) $path);
|
||||
$path = (string) $path;
|
||||
// For backwards compatibility, do not strip a couple of specific javascript
|
||||
// paths that are harmless.
|
||||
// @see https://www.drupal.org/project/drupal/issues/3310081
|
||||
$skip_js_paths = array('javascript:void()', 'javascript:void();', 'javascript:void(0)', 'javascript:void(0);');
|
||||
if (!in_array(strtolower($path), $skip_js_paths)) {
|
||||
$path = drupal_strip_dangerous_protocols($path);
|
||||
}
|
||||
if ($use_theme) {
|
||||
return theme('link', array('text' => $text, 'path' => $path, 'options' => $options));
|
||||
}
|
||||
|
|
|
@ -97,6 +97,20 @@ class CommonURLUnitTest extends DrupalWebTestCase {
|
|||
$path = "javascript:alert('XSS')";
|
||||
$link = l($text, $path, array('external' => TRUE));
|
||||
$this->assertTrue(strpos($link, 'javascript:') === FALSE, 'Dangerous protocol javascript: was sanitized.');
|
||||
|
||||
// Verify that these harmless javascript paths are left intact for BC.
|
||||
$special_case_js_paths = array(
|
||||
'javascript:void()',
|
||||
'javascript:void();',
|
||||
'javascript:void(0)',
|
||||
'javascript:void(0);',
|
||||
'JavaScript:Void(0)'
|
||||
);
|
||||
foreach ($special_case_js_paths as $path) {
|
||||
$text = $this->randomName();
|
||||
$link = l($text, $path, array('external' => TRUE));
|
||||
$this->assertTrue(strpos($link, $path) !== FALSE, format_string('Harmless @path was not sanitized.', array('@path' => $path)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue