-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #751 from shinya/eccube-2.17.2-p2
Patch/2.17.2-p2
- Loading branch information
Showing
3 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
require 'data/smarty_extends/modifier.script_escape.php'; | ||
|
||
/** | ||
* | ||
*/ | ||
class Modifier_ScriptEscapeTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function scriptEscapeProvider() | ||
{ | ||
return array( | ||
array('<script type="text/javascript"></script>'), | ||
array('<svg onload="alert(1)">test</svg>'), | ||
array('<img onload="alert(1)">test</img>'), | ||
array('<body onload="alert(1)">test</body>'), | ||
array('<iframe></iframe>'), | ||
array('<object></object>'), | ||
array('<embed>'), | ||
array('\"onclick=\"alert(1)\"'), | ||
array('<p onclick="alert(1)">test</p>'), | ||
array('<p onsubmit="alert(1)">test</p>'), | ||
array('<p style="" onclick="alert(1)">test</p>'), | ||
array('<input type="button"onfocus="alert(1)">'), | ||
array('<input type="button" onblur="alert(1)">'), | ||
array('<input onfocus="alert(1)" type="button">'), | ||
array('<body onresize="alert(1)">'), | ||
array('<div onscroll="alert(1)">'), | ||
array('<div>javascript:test()</div>'), | ||
array('<input type="button" ondblclick="alert(1)">'), | ||
array('<input type="text" onchange="alert(1);">'), | ||
array('<input type="text" onselect="alert(1);">'), | ||
array('<form onsubmit="alert(1);">'), | ||
array('<input type="button" onkeydown="alert(1)">'), | ||
array('<input type="button" onkeypress="alert(1)">'), | ||
array('<input type="button" onkeyup="alert(1)">'), | ||
array('<input type=\"button\"\nonclick=\"alert(1)\">'), | ||
array('<div/onscroll="alert(1)">'), | ||
); | ||
} | ||
|
||
public function scriptNoEscapeProvider() | ||
{ | ||
return array( | ||
array('<p>test</p>'), | ||
array('<input type="button">'), | ||
array('<p>onclick</p>'), | ||
array('<div>test</div>'), | ||
array('<textarea>onclick="alert(1)";</textarea>'), | ||
array('<p>onclick="\ntest();"</p>'), | ||
array('<onclock'), | ||
array('<oncl\nick'), | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider scriptEscapeProvider | ||
*/ | ||
public function testメールテンプレート_エスケープされる($value) | ||
{ | ||
$ret = smarty_modifier_script_escape($value); | ||
$pattern = "/#script tag escaped#/"; | ||
$this->assertRegExp($pattern, $ret); | ||
} | ||
|
||
/** | ||
* @dataProvider scriptNoEscapeProvider | ||
*/ | ||
public function testメールテンプレート_エスケープされない($value) | ||
{ | ||
$ret = smarty_modifier_script_escape($value); | ||
$pattern = "/#script tag escaped#/"; | ||
$this->assertNotRegExp($pattern, $ret); | ||
} | ||
} |