mirror of
https://github.com/filp/whoops.git
synced 2026-09-16 04:36:20 +00:00
Prevent possible XSS via target="_blank" urls (#533)
This commit is contained in:
committed by
Denis Sokolov
parent
a50d24d81a
commit
9e7c2ea58c
@@ -88,7 +88,7 @@ class TemplateHelper
|
||||
$escaped = $this->escape($raw);
|
||||
return preg_replace(
|
||||
"@([A-z]+?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@",
|
||||
"<a href=\"$1\" target=\"_blank\">$1</a>",
|
||||
"<a href=\"$1\" target=\"_blank\" rel=\"noreferrer noopener\">$1</a>",
|
||||
$escaped
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class TemplateHelperTest extends TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
$this->helper->escapeButPreserveUris($original),
|
||||
"This is a <a href=''><a href=\"http://google.com\" target=\"_blank\">http://google.com</a></a> test string"
|
||||
"This is a <a href=''><a href=\"http://google.com\" target=\"_blank\" rel=\"noreferrer noopener\">http://google.com</a></a> test string"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user