Issue #2990723 by poker10, tatarbj, DamienMcKenna: Security improvement for l() function
parent
b807051feb
commit
9b89fa9c19
|
@ -2570,6 +2570,7 @@ function l($text, $path, array $options = array()) {
|
|||
$use_theme = FALSE;
|
||||
}
|
||||
}
|
||||
$path = drupal_strip_dangerous_protocols((string) $path);
|
||||
if ($use_theme) {
|
||||
return theme('link', array('text' => $text, 'path' => $path, 'options' => $options));
|
||||
}
|
||||
|
|
|
@ -91,6 +91,12 @@ class CommonURLUnitTest extends DrupalWebTestCase {
|
|||
$link = l($text, $path);
|
||||
$sanitized_path = check_url(url($path));
|
||||
$this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered', array('@path' => $path)));
|
||||
|
||||
// Verify that a dangerous protocol is sanitized.
|
||||
$text = $this->randomName();
|
||||
$path = "javascript:alert('XSS')";
|
||||
$link = l($text, $path, array('external' => TRUE));
|
||||
$this->assertTrue(strpos($link, 'javascript:') === FALSE, 'Dangerous protocol javascript: was sanitized.');
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue