devtoolboxuk /
soteria
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace devtoolboxuk\soteria; |
||
| 4 | |||
| 5 | use PHPUnit\Framework\TestCase; |
||
| 6 | |||
| 7 | class UrlTest extends TestCase |
||
| 8 | { |
||
| 9 | private $security; |
||
| 10 | |||
| 11 | function __construct($name = null, array $data = [], $dataName = '') |
||
|
0 ignored issues
–
show
|
|||
| 12 | { |
||
| 13 | parent::__construct($name, $data, $dataName); |
||
| 14 | $this->security = new SoteriaService(); |
||
| 15 | } |
||
| 16 | |||
| 17 | private function _testArray() |
||
| 18 | { |
||
| 19 | return [ |
||
| 20 | '<a href="http://www.chaos.org/">www.chaos.org</a>', |
||
| 21 | '<a name="X">Short \'a name\' tag</a>', |
||
| 22 | '<td colspan="3" rowspan="5">Foo</td>', |
||
| 23 | '<td colspan=3 rowspan=5>Foo</td>', |
||
| 24 | '<td colspan=\'3\' rowspan=\'5\'>Foo</td>', |
||
| 25 | '<td rowspan="2" class="mugwump" style="background-color: rgb(255, 204 204);">Bar</td>', |
||
| 26 | '<td nowrap>Very Long String running to 1000 characters...</td>', |
||
| 27 | '<td bgcolor="#00ff00" nowrap>Very Long String with a blue background</td>', |
||
| 28 | '<a href="proto1://www.foo.com">New protocol test</a>', |
||
| 29 | '<img src="proto2://www.foo.com" />', |
||
| 30 | '<a href="javascript:javascript:javascript:javascript:javascript:alert(\'Boo!\');">bleep</a>', |
||
| 31 | '<a href="proto4://abc.xyz.foo.com">Another new protocol</a>', |
||
| 32 | '<a href="proto9://foo.foo.foo.foo.foo.org/">Test of "proto9"</a>', |
||
| 33 | '<td width="75">Bar!</td>', |
||
| 34 | '<td width="200">Long Cell</td>', |
||
| 35 | 'search.php?q=%22%3Balert(%22XSS%22)%3B&n=1093&i=410', |
||
| 36 | 'http://localhost/text.php/"><script>alert(“Gehackt!”);</script></form><form action="/...', |
||
| 37 | ]; |
||
| 38 | } |
||
| 39 | |||
| 40 | private function _resultArray() |
||
| 41 | { |
||
| 42 | return [ |
||
| 43 | '<a href="http://www.chaos.org/">www.chaos.org</a>', |
||
| 44 | '<a name="X">Short \'a name\' tag</a>', |
||
| 45 | '<td colspan="3" rowspan="5">Foo</td>', |
||
| 46 | '<td colspan=3 rowspan=5>Foo</td>', |
||
| 47 | '<td colspan=\'3\' rowspan=\'5\'>Foo</td>', |
||
| 48 | '<td rowspan="2" class="mugwump" >Bar</td>', |
||
| 49 | '<td nowrap>Very Long String running to 1000 characters...</td>', |
||
| 50 | '<td bgcolor="#00ff00" nowrap>Very Long String with a blue background</td>', |
||
| 51 | '<a href="proto1://www.foo.com">New protocol test</a>', |
||
| 52 | '<img src="proto2://www.foo.com" />', |
||
| 53 | '<a href="">bleep</a>', |
||
| 54 | '<a href="proto4://abc.xyz.foo.com">Another new protocol</a>', |
||
| 55 | '<a href="proto9://foo.foo.foo.foo.foo.org/">Test of "proto9"</a>', |
||
| 56 | '<td width="75">Bar!</td>', |
||
| 57 | '<td width="200">Long Cell</td>', |
||
| 58 | 'search.php?q=";alert("XSS");&n=1093&i=410', |
||
| 59 | 'http://localhost/text.php/">alert(Gehackt!);</form><form action="/...', |
||
| 60 | ]; |
||
| 61 | } |
||
| 62 | |||
| 63 | private function _resultIsFoundArray() |
||
| 64 | { |
||
| 65 | return [ |
||
| 66 | false, |
||
| 67 | false, |
||
| 68 | false, |
||
| 69 | false, |
||
| 70 | false, |
||
| 71 | true, |
||
| 72 | false, |
||
| 73 | false, |
||
| 74 | false, |
||
| 75 | false, |
||
| 76 | true, |
||
| 77 | false, |
||
| 78 | false, |
||
| 79 | false, |
||
| 80 | false, |
||
| 81 | true, |
||
| 82 | true |
||
| 83 | ]; |
||
| 84 | } |
||
| 85 | |||
| 86 | function testIsXssFoundArray() |
||
|
0 ignored issues
–
show
|
|||
| 87 | { |
||
| 88 | $xss = $this->security->xss(true); |
||
| 89 | |||
| 90 | $testArray = $this->_testArray(); |
||
| 91 | $result = $this->_resultIsFoundArray(); |
||
| 92 | |||
| 93 | foreach ($testArray as $key => $string) { |
||
| 94 | $xss->cleanUrl($string); |
||
|
0 ignored issues
–
show
The method
cleanUrl does only exist in devtoolboxuk\soteria\handlers\Xss, but not in devtoolboxuk\soteria\handlers\Sanitise.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 95 | $this->assertSame($xss->isXssFound(), $result[$key]); |
||
|
0 ignored issues
–
show
The method
isXssFound does only exist in devtoolboxuk\soteria\handlers\Xss, but not in devtoolboxuk\soteria\handlers\Sanitise.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | function testArray() |
||
|
0 ignored issues
–
show
|
|||
| 100 | { |
||
| 101 | $xss = $this->security->xss(true); |
||
| 102 | |||
| 103 | $testArray = $this->_testArray(); |
||
| 104 | $resultArray = $this->_resultArray(); |
||
| 105 | |||
| 106 | $this->assertSame($resultArray, $xss->cleanUrl($testArray)); |
||
|
0 ignored issues
–
show
The method
cleanUrl does only exist in devtoolboxuk\soteria\handlers\Xss, but not in devtoolboxuk\soteria\handlers\Sanitise.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Test is from voku/anti-xss |
||
| 111 | */ |
||
| 112 | public function testFromJsXss() |
||
| 113 | { |
||
| 114 | |||
| 115 | // 兼容各种奇葩输入 |
||
| 116 | $this->assertSame('', $this->security->xss(true)->cleanUrl('')); |
||
|
0 ignored issues
–
show
The method
cleanUrl does only exist in devtoolboxuk\soteria\handlers\Xss, but not in devtoolboxuk\soteria\handlers\Sanitise.
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
| 117 | $this->assertNull($this->security->xss(true)->cleanUrl(null)); |
||
| 118 | $this->assertSame(123, $this->security->xss(true)->cleanUrl(123)); |
||
| 119 | $this->assertSame('{a: 1111}', $this->security->xss(true)->cleanUrl('{a: 1111}')); |
||
| 120 | // 清除不可见字符 |
||
| 121 | // $this->assertSame("a b", $this->security->xss(true)->cleanUrl("a\u0000\u0001\u0002\u0003\r\n b")); |
||
| 122 | // 过滤不在白名单的标签 |
||
| 123 | $this->assertSame('<b>abcd</b>', $this->security->xss(true)->cleanUrl('<b>abcd</b>')); |
||
| 124 | $this->assertSame('<o>abcd</o>', $this->security->xss(true)->cleanUrl('<o>abcd</o>')); |
||
| 125 | $this->assertSame('<b>abcd</o>', $this->security->xss(true)->cleanUrl('<b>abcd</o>')); |
||
| 126 | $this->assertSame('<b><o>abcd</b></o>', $this->security->xss(true)->cleanUrl('<b><o>abcd</b></o>')); |
||
| 127 | $this->assertSame('<hr>', $this->security->xss(true)->cleanUrl('<hr>')); |
||
| 128 | $this->assertSame('<xss>', $this->security->xss(true)->cleanUrl('<xss>')); |
||
| 129 | $this->assertSame('<xss o="x">', $this->security->xss(true)->cleanUrl('<xss o="x">')); |
||
| 130 | $this->assertSame('<a><b>c</b></a>', $this->security->xss(true)->cleanUrl('<a><b>c</b></a>')); |
||
| 131 | $this->assertSame('<a><c>b</c></a>', $this->security->xss(true)->cleanUrl('<a><c>b</c></a>')); |
||
| 132 | // 过滤不是标签的<> |
||
| 133 | $this->assertSame('<>>', $this->security->xss(true)->cleanUrl('<>>')); |
||
| 134 | $this->assertSame("''", $this->security->xss(true)->cleanUrl("'<scri' + 'pt>'")); |
||
| 135 | $this->assertSame("''", $this->security->xss(true)->cleanUrl("'<script' + '>'")); |
||
| 136 | $this->assertSame('<<a>b>', $this->security->xss(true)->cleanUrl('<<a>b>')); |
||
| 137 | $this->assertSame('<<<a>>b</a><x>', $this->security->xss(true)->cleanUrl('<<<a>>b</a><x>')); |
||
| 138 | // 过滤不在白名单中的属性 |
||
| 139 | $this->assertSame('<a oo="1" xx="2" title="3">yy</a>', $this->security->xss(true)->cleanUrl('<a oo="1" xx="2" title="3">yy</a>')); |
||
| 140 | $this->assertSame('<a >pp</a>', $this->security->xss(true)->cleanUrl('<a title xx oo>pp</a>')); |
||
| 141 | $this->assertSame('<a >pp</a>', $this->security->xss(true)->cleanUrl('<a title "">pp</a>')); |
||
| 142 | $this->assertSame('<a t="">', $this->security->xss(true)->cleanUrl('<a t="">')); |
||
| 143 | // 属性内的特殊字符 |
||
| 144 | $this->assertSame('<a >>">', $this->security->xss(true)->cleanUrl('<a title="\'<<>>">')); |
||
| 145 | $this->assertSame('<a title="">', $this->security->xss(true)->cleanUrl('<a title=""">')); |
||
| 146 | $this->assertSame('<a title="oo">', $this->security->xss(true)->cleanUrl('<a h=title="oo">')); |
||
| 147 | $this->assertSame('<a title="oo">', $this->security->xss(true)->cleanUrl('<a h= title="oo">')); |
||
| 148 | $this->assertSame('<a title="alert(/xss/)">', $this->security->xss(true)->cleanUrl('<a title="javascript:alert(/xss/)">')); |
||
| 149 | // 自动将属性值的单引号转为双引号 |
||
| 150 | $this->assertSame('<a title=\'abcd\'>', $this->security->xss(true)->cleanUrl('<a title=\'abcd\'>')); |
||
| 151 | $this->assertSame('<a title=\'"\'>', $this->security->xss(true)->cleanUrl('<a title=\'"\'>')); |
||
| 152 | // 没有双引号括起来的属性值 |
||
| 153 | $this->assertSame('<a >', $this->security->xss(true)->cleanUrl('<a title=home>')); |
||
| 154 | $this->assertSame('<a >', $this->security->xss(true)->cleanUrl('<a title=abc("d")>')); |
||
| 155 | $this->assertSame('<a >', $this->security->xss(true)->cleanUrl('<a title=abc(\'d\')>')); |
||
| 156 | // 单个闭合标签 |
||
| 157 | $this->assertSame('<img />', $this->security->xss(true)->cleanUrl('<img src/>')); |
||
| 158 | $this->assertSame('<img />', $this->security->xss(true)->cleanUrl('<img src />')); |
||
| 159 | $this->assertSame('<img />', $this->security->xss(true)->cleanUrl('<img src//>')); |
||
| 160 | $this->assertSame('<br />', $this->security->xss(true)->cleanUrl('<br />')); |
||
| 161 | $this->assertSame('<br/>', $this->security->xss(true)->cleanUrl('<br/>')); |
||
| 162 | // 畸形属性格式 |
||
| 163 | $this->assertSame('<a target = "_blank" title ="bbb">', $this->security->xss(true)->cleanUrl('<a target = "_blank" title ="bbb">')); |
||
| 164 | $this->assertSame('<a target = \'_blank\' title =\'bbb\'>', $this->security->xss(true)->cleanUrl("<a target = '_blank' title ='bbb'>")); |
||
| 165 | $this->assertSame('<a >', $this->security->xss(true)->cleanUrl('<a target=_blank title=bbb>')); |
||
| 166 | $this->assertSame('<a target = "_blank" title = "bbb">', $this->security->xss(true)->cleanUrl('<a target = "_blank" title = title = "bbb">')); |
||
| 167 | $this->assertSame('<a target = " _blank " title = "bbb">', $this->security->xss(true)->cleanUrl('<a target = " _blank " title = title = "bbb">')); |
||
| 168 | $this->assertSame('<a title = "bbb">', $this->security->xss(true)->cleanUrl('<a target = _blank title = title = "bbb">')); |
||
| 169 | $this->assertSame('<a title = "bbb">', $this->security->xss(true)->cleanUrl('<a target = ' . 0x42 . '_blank' . 0x42 . ' title = title = "bbb">')); |
||
| 170 | $this->assertSame('<img title="xxx">', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title="xxx">')); |
||
| 171 | $this->assertSame('<img >', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title=xxx>')); |
||
| 172 | $this->assertSame('<img >', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title= xxx>')); |
||
| 173 | $this->assertSame('<img title= "xxx">', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title= "xxx">')); |
||
| 174 | $this->assertSame('<img title= \'xxx\'>', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title= \'xxx\'>')); |
||
| 175 | $this->assertSame('<img title = \'xxx\'>', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title = \'xxx\'>')); |
||
| 176 | $this->assertSame('<img title= "xxx" alt="yyy">', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title= "xxx" no=yes alt="yyy">')); |
||
| 177 | $this->assertSame('<img title= "xxx" alt="\'yyy\'">', $this->security->xss(true)->cleanUrl('<img width = 100 height =200 title= "xxx" no=yes alt="\'yyy\'">')); |
||
| 178 | // 过滤所有标签 |
||
| 179 | $this->assertSame('<a title="xx">bb</a>', $this->security->xss(true)->cleanUrl('<a title="xx">bb</a>')); |
||
| 180 | $this->assertSame('<hr>', $this->security->xss(true)->cleanUrl('<hr>')); |
||
| 181 | // 增加白名单标签及属性 |
||
| 182 | $this->assertSame('<ooxx yy="ok" cc="no">uu</ooxx>', $this->security->xss(true)->cleanUrl('<ooxx yy="ok" cc="no">uu</ooxx>')); |
||
| 183 | $this->assertSame('>">\'>alert(String.fromCharCode(88,83,83))', $this->security->xss(true)->cleanUrl('></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>')); |
||
| 184 | $this->assertSame(';!--"<XSS>=', $this->security->xss(true)->cleanUrl(';!--"<XSS>=&{()}')); |
||
| 185 | $this->assertSame('', $this->security->xss(true)->cleanUrl('<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>')); |
||
| 186 | $this->assertSame('<IMG src="">', $this->security->xss(true)->cleanUrl('<IMG SRC="javascript:alert(\'XSS\');">')); |
||
| 187 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=javascript:alert(\'XSS\')>')); |
||
| 188 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=JaVaScRiPt:alert(\'XSS\')>')); |
||
| 189 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=`javascript:alert("RSnake says, \'XSS\'")`>')); |
||
| 190 | $this->assertSame('<IMG """><>>', $this->security->xss(true)->cleanUrl('<IMG """><SCRIPT>alert("XSS")</SCRIPT>">')); |
||
| 191 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>')); |
||
| 192 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=javascript:alert('XSS')>')); |
||
| 193 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=javascript:alert('XSS')>')); |
||
| 194 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=javascript:alert('XSS')>')); |
||
| 195 | $this->assertSame('<IMG src="">', $this->security->xss(true)->cleanUrl('<IMG SRC="jav ascript:alert(\'XSS\');">')); |
||
| 196 | $this->assertSame('<IMG src="">', $this->security->xss(true)->cleanUrl('<IMG SRC="jav	ascript:alert(\'XSS\');">')); |
||
| 197 | $this->assertSame('<IMG src="">', $this->security->xss(true)->cleanUrl('<IMG SRC="jav\nascript:alert(\'XSS\');">')); |
||
| 198 | $this->assertSame('<IMG >', $this->security->xss(true)->cleanUrl('<IMG SRC=java\0script:alert(\"XSS\")>')); |
||
| 199 | $this->assertSame('<IMG src="">', $this->security->xss(true)->cleanUrl('<IMG SRC="  javascript:alert(\'XSS\');">')); |
||
| 200 | $this->assertSame('', $this->security->xss(true)->cleanUrl('<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>')); |
||
| 201 | $this->assertSame('<BODY !#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>', $this->security->xss(true)->cleanUrl('<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>')); |
||
| 202 | $this->assertSame('<BODY !#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>', $this->security->xss(true)->cleanUrl('<BODY onload !#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>')); |
||
| 203 | $this->assertSame('<alert("XSS");//<', $this->security->xss(true)->cleanUrl('<<SCRIPT>alert("XSS");//<</SCRIPT>')); |
||
| 204 | $this->assertSame('', $this->security->xss(true)->cleanUrl('<SCRIPT SRC=http://ha.ckers.org/xss.js?< B >')); |
||
| 205 | $this->assertSame('<SCRIPT SRC=//ha.ckers.org/.j', $this->security->xss(true)->cleanUrl('<SCRIPT SRC=//ha.ckers.org/.j')); |
||
| 206 | $this->assertSame('<IMG src=""', $this->security->xss(true)->cleanUrl('<IMG SRC="javascript:alert(\'XSS\')"')); |
||
| 207 | $this->assertSame('<iframe src=http://ha.ckers.org/scriptlet.html <', $this->security->xss(true)->cleanUrl('<iframe src=http://ha.ckers.org/scriptlet.html <')); |
||
| 208 | // 过滤 javascript: |
||
| 209 | $this->assertSame('<a >', $this->security->xss(true)->cleanUrl('<a style="url(\'javascript:alert(1)\')">')); |
||
| 210 | $this->assertSame('<td background="url(\'alert(1)\')">', $this->security->xss(true)->cleanUrl('<td background="url(\'javascript:alert(1)\')">')); |
||
| 211 | // 过滤 style |
||
| 212 | $this->assertSame('<DIV >', $this->security->xss(true)->cleanUrl('<DIV STYLE="width: \nexpression(alert(1));">')); |
||
| 213 | $this->assertSame('<DIV >', $this->security->xss(true)->cleanUrl('<DIV STYLE="width: \n expressionexpression((alert(1));">')); |
||
| 214 | // 不正常的url |
||
| 215 | $this->assertSame('<DIV >', $this->security->xss(true)->cleanUrl('<DIV STYLE="background:\n url (javascript:ooxx);">')); |
||
| 216 | $this->assertSame('<DIV >', $this->security->xss(true)->cleanUrl('<DIV STYLE="background:url (javascript:ooxx);">')); |
||
| 217 | // 正常的url |
||
| 218 | $this->assertSame('<DIV >', $this->security->xss(true)->cleanUrl('<DIV STYLE="background: url (ooxx);">')); |
||
| 219 | $this->assertSame('<IMG src="">', $this->security->xss(true)->cleanUrl('<IMG SRC=\'vbscript:msgbox("XSS")\'>')); |
||
| 220 | $this->assertSame('<IMG SRC="[code]">', $this->security->xss(true)->cleanUrl('<IMG SRC="livescript:[code]">')); |
||
| 221 | $this->assertSame('<IMG SRC="[code]">', $this->security->xss(true)->cleanUrl('<IMG SRC="mocha:[code]">')); |
||
| 222 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="javas/**/cript:alert(\'XSS\');">')); |
||
| 223 | $this->assertSame('<a href="test">', $this->security->xss(true)->cleanUrl('<a href="javascript:test">')); |
||
| 224 | $this->assertSame('<a href="/javascript/a">', $this->security->xss(true)->cleanUrl('<a href="/javascript/a">')); |
||
| 225 | $this->assertSame('<a href="/javascript/a">', $this->security->xss(true)->cleanUrl('<a href="/javascript/a">')); |
||
| 226 | $this->assertSame('<a href="http://aa.com">', $this->security->xss(true)->cleanUrl('<a href="http://aa.com">')); |
||
| 227 | $this->assertSame('<a href="https://aa.com">', $this->security->xss(true)->cleanUrl('<a href="https://aa.com">')); |
||
| 228 | $this->assertSame('<a href="mailto:[email protected]">', $this->security->xss(true)->cleanUrl('<a href="mailto:[email protected]">')); |
||
| 229 | $this->assertSame('<a href="#hello">', $this->security->xss(true)->cleanUrl('<a href="#hello">')); |
||
| 230 | $this->assertSame('<a href="other">', $this->security->xss(true)->cleanUrl('<a href="other">')); |
||
| 231 | // 这个暂时不知道怎么处理 |
||
| 232 | //self::assertSame($this->security->xss(true)->cleanUrl('¼script¾alert(¢XSS¢)¼/script¾'), ''); |
||
| 233 | $this->assertSame('<!--[if gte IE 4]>alert(\'XSS\');<![endif]--> END', $this->security->xss(true)->cleanUrl('<!--[if gte IE 4]><SCRIPT>alert(\'XSS\');</SCRIPT><![endif]--> END')); |
||
| 234 | $this->assertSame('<!--[if gte IE 4]>alert(\'XSS\');<![endif]--> END', $this->security->xss(true)->cleanUrl('<!--[if gte IE 4]><SCRIPT >alert(\'XSS\');</SCRIPT><![endif]--> END')); |
||
| 235 | // HTML5新增实体编码 冒号: 换行
 |
||
| 236 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="javascript:alert(/xss/)">')); |
||
| 237 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="javascript&colonalert(/xss/)">')); |
||
| 238 | $this->assertSame('<a href="a
b">', $this->security->xss(true)->cleanUrl('<a href="a
b">')); |
||
| 239 | $this->assertSame('<a href="a&NewLineb">', $this->security->xss(true)->cleanUrl('<a href="a&NewLineb">')); |
||
| 240 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="javasc
ript:alert(1)">')); |
||
| 241 | // data URI 协议过滤 |
||
| 242 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="data:">')); |
||
| 243 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="d a t a : ">')); |
||
| 244 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="data: html/text;">')); |
||
| 245 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="data:html/text;">')); |
||
| 246 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="data:html /text;">')); |
||
| 247 | $this->assertSame('<a href="">', $this->security->xss(true)->cleanUrl('<a href="data: image/text;">')); |
||
| 248 | $this->assertSame('<img src="">', $this->security->xss(true)->cleanUrl('<img src="data: aaa/text;">')); |
||
| 249 | $this->assertSame('<img src="">', $this->security->xss(true)->cleanUrl('<img src="data:image/png; base64; ofdkofiodiofl">')); |
||
| 250 | $this->assertSame('<img src="PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">', $this->security->xss(true)->cleanUrl('<img src="data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">')); |
||
| 251 | // HTML备注处理 |
||
| 252 | $this->assertSame('<!-- -->', $this->security->xss(true)->cleanUrl('<!-- -->')); |
||
| 253 | $this->assertSame('<!-- a -->', $this->security->xss(true)->cleanUrl('<!-- a -->')); |
||
| 254 | $this->assertSame('<!--sa -->ss', $this->security->xss(true)->cleanUrl('<!--sa -->ss')); |
||
| 255 | $this->assertSame('<!-- ', $this->security->xss(true)->cleanUrl('<!-- ')); |
||
| 256 | } |
||
| 257 | |||
| 258 | } |
||
| 259 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.