Skip to content

Commit 11ab3dd

Browse files
committed
fixed XSS protection
1 parent df96135 commit 11ab3dd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

demo/index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66

77
function get($name, $default = '')
88
{
9-
if($name == 'url') {
10-
if(filter_var($_GET['url'], FILTER_VALIDATE_URL)) {
9+
if (!isset($_GET[$name])) {
10+
return $default;
11+
}
12+
13+
if ($name === 'url') {
14+
if (!filter_var($_GET['url'], FILTER_VALIDATE_URL)) {
1115
return 'http://doNotTryToXSS.invalid';
1216
}
1317
}
14-
return isset($_GET[$name]) ? $_GET[$name] : $default;
18+
19+
return $_GET[$name];
1520
}
1621

1722
function getEscaped($name, $default = '')

0 commit comments

Comments
 (0)