|
|
@@ -347,6 +347,11 @@ class HtmlHelperTest extends TestCase
|
|
|
$result = $this->Html->image('cid:cakephp_logo');
|
|
|
$expected = ['img' => ['src' => 'cid:cakephp_logo', 'alt' => '']];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ $result = $this->Html->image('x:"><script>alert(1)</script>');
|
|
|
+ $expected = ['img' => ['src' => 'x:"><script>alert(1)</script>', 'alt' => '']];
|
|
|
+
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -562,6 +567,10 @@ class HtmlHelperTest extends TestCase
|
|
|
$expected['link']['href'] = 'css/screen.css?with=param&other=param';
|
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
+ $result = $this->Html->css('x:"><script>alert(1)</script>');
|
|
|
+ $expected['link']['href'] = 'x:"><script>alert(1)</script>';
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+
|
|
|
$result = $this->Html->css('http://whatever.com/screen.css?1234');
|
|
|
$expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/';
|
|
|
$this->assertHtml($expected, $result);
|
|
|
@@ -904,6 +913,12 @@ class HtmlHelperTest extends TestCase
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
+ $result = $this->Html->script('x:"><script>alert(1)</script>');
|
|
|
+ $expected = [
|
|
|
+ 'script' => ['src' => 'x:"><script>alert(1)</script>']
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+
|
|
|
$result = $this->Html->script('foo2', ['pathPrefix' => '/my/custom/path/']);
|
|
|
$expected = [
|
|
|
'script' => ['src' => '/my/custom/path/foo2.js']
|
|
|
@@ -1716,6 +1731,24 @@ class HtmlHelperTest extends TestCase
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
+ $result = $this->Html->meta('icon', 'x:"><script>alert(1)</script>');
|
|
|
+ $url = 'x:"><script>alert(1)</script>';
|
|
|
+ $expected = [
|
|
|
+ 'link' => [
|
|
|
+ 'href' => $url,
|
|
|
+ 'type' => 'image/x-icon',
|
|
|
+ 'rel' => 'icon'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'link' => [
|
|
|
+ 'href' => $url,
|
|
|
+ 'type' => 'image/x-icon',
|
|
|
+ 'rel' => 'shortcut icon'
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+
|
|
|
$this->Html->request->webroot = '/testing/';
|
|
|
$result = $this->Html->meta('icon');
|
|
|
$expected = [
|
|
|
@@ -1956,6 +1989,12 @@ class HtmlHelperTest extends TestCase
|
|
|
$result = $this->Html->div('class-name', '<text>', ['escape' => true]);
|
|
|
$expected = ['div' => ['class' => 'class-name'], '<text>', '/div'];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
+
|
|
|
+ $evilKey = "><script>alert(1)</script>";
|
|
|
+ $options = [$evilKey => 'some value'];
|
|
|
+ $result = $this->Html->div('class-name', '', $options);
|
|
|
+ $expected = '<div ><script>alert(1)</script>="some value" class="class-name"></div>';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|