Skip to content
Snippets Groups Projects
Commit c381d7c6 authored by catch's avatar catch
Browse files

Issue #2503063 by alexpott, Lendude: Removing XssTest causes test failures due...

Issue #2503063 by alexpott, Lendude: Removing XssTest causes test failures due to UrlHelper's static $allowedProtocols

(cherry picked from commit a47bf769)
parent fedcff24
No related branches found
No related tags found
22 merge requests!8394[warning] array_flip(): Can only flip STRING and INTEGER values, when saving a non-revisionable custom content entity,!7780issue 3443822: fix for 'No route found for the specified format html. Supported formats: json, xml.',!5013Issue #3071143: Table Render Array Example Is Incorrect,!4848Issue #1566662: Update module should send notifications on Thursdays,!4792Issue #2230689: Remove redundant "Italic" style,!4220Issue #3368223: Link field > Access to internal links is not checked on display.,!3884Issue #3356842,!3870Issue #3087868,!3812Draft: Issue #3339373 by alexpott, andypost, mondrake:...,!3686Issue #3219967 against 9.5.x,!3683Issue #2939397: Clearing AliasManager cache with root path raises warning,!3543Issue #3344259: Allow ajax dialog to have focus configurable,!3356Issue #3209129: Scrolling problems when adding a block via layout builder,!2280Issue #3280415: Metapackage Generator Breaks Under Composer --no-dev,!2205Quote all names in the regions section.,!2050Issue #3272969: Remove UnqiueField constraint.,!1956Issue #3268872: hook_views_invalidate_cache not called when a view is deleted,!1893Issue #3217260: Add a way to make media captions not editable in CKEditor,!1459Issue #3087632: menu_name max length is too long,!878Issue #3221534: throw an exception when IDs passed to loadMultiple() are badly formed,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!204Issue #3040556: It is not possible to react to an entity being duplicated
...@@ -18,8 +18,13 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase { ...@@ -18,8 +18,13 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase {
/** /**
* @covers ::validate * @covers ::validate
* @dataProvider providerValidate * @dataProvider providerValidate
* @runInSeparateProcess
*/ */
public function testValidate($value, $valid) { public function testValidate($url, $valid) {
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn(Url::fromUri($url));
$context = $this->createMock(ExecutionContextInterface::class); $context = $this->createMock(ExecutionContextInterface::class);
if ($valid) { if ($valid) {
...@@ -38,7 +43,7 @@ public function testValidate($value, $valid) { ...@@ -38,7 +43,7 @@ public function testValidate($value, $valid) {
$validator = new LinkExternalProtocolsConstraintValidator(); $validator = new LinkExternalProtocolsConstraintValidator();
$validator->initialize($context); $validator->initialize($context);
$validator->validate($value, $constraint); $validator->validate($link, $constraint);
} }
/** /**
...@@ -56,15 +61,6 @@ public function providerValidate() { ...@@ -56,15 +61,6 @@ public function providerValidate() {
// Invalid protocols. // Invalid protocols.
$data[] = ['ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt', FALSE]; $data[] = ['ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt', FALSE];
foreach ($data as &$single_data) {
$url = Url::fromUri($single_data[0]);
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn($url);
$single_data[0] = $link;
}
return $data; return $data;
} }
......
...@@ -449,6 +449,8 @@ public static function providerTestIsExternal() { ...@@ -449,6 +449,8 @@ public static function providerTestIsExternal() {
* Expected escaped value. * Expected escaped value.
* @param array $protocols * @param array $protocols
* Protocols to allow. * Protocols to allow.
*
* @runInSeparateProcess
*/ */
public function testFilterBadProtocol($uri, $expected, $protocols) { public function testFilterBadProtocol($uri, $expected, $protocols) {
UrlHelper::setAllowedProtocols($protocols); UrlHelper::setAllowedProtocols($protocols);
...@@ -488,6 +490,8 @@ public static function providerTestFilterBadProtocol() { ...@@ -488,6 +490,8 @@ public static function providerTestFilterBadProtocol() {
* Expected escaped value. * Expected escaped value.
* @param array $protocols * @param array $protocols
* Protocols to allow. * Protocols to allow.
*
* @runInSeparateProcess
*/ */
public function testStripDangerousProtocols($uri, $expected, $protocols) { public function testStripDangerousProtocols($uri, $expected, $protocols) {
UrlHelper::setAllowedProtocols($protocols); UrlHelper::setAllowedProtocols($protocols);
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* Relevant CVEs: * Relevant CVEs:
* - CVE-2002-1806, ~CVE-2005-0682, ~CVE-2005-2106, CVE-2005-3973, * - CVE-2002-1806, ~CVE-2005-0682, ~CVE-2005-2106, CVE-2005-3973,
* CVE-2006-1226 (= rev. 1.112?), CVE-2008-0273, CVE-2008-3740. * CVE-2006-1226 (= rev. 1.112?), CVE-2008-0273, CVE-2008-3740.
*
* @runTestsInSeparateProcesses
*/ */
class XssTest extends TestCase { class XssTest extends TestCase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment