Skip to content

Commit

Permalink
Merge pull request #8848 from mmcev106/urlencode
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Dec 6, 2022
2 parents 1cd10c3 + 9764803 commit 4dc969b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions stubs/CoreGenericFunctions.phpstub
Expand Up @@ -837,6 +837,15 @@ function htmlspecialchars(string $string, int $flags = ENT_COMPAT | ENT_HTML401,
*/
function htmlspecialchars_decode(string $string, ?int $flags = null) : string {}

/**
* @psalm-pure
*
* @psalm-taint-escape html
* @psalm-taint-escape has_quotes
* @psalm-flow ($string) -> return
*/
function urlencode(string $string) : string {}

/**
* @psalm-pure
*
Expand Down
16 changes: 16 additions & 0 deletions tests/TaintTest.php
Expand Up @@ -722,6 +722,11 @@ function bar(array $arr): void {
}
}'
],
'urlencode' => [
'code' => '<?php
echo urlencode($_GET["bad"]);
'
],
];
}

Expand Down Expand Up @@ -2373,6 +2378,17 @@ public static function getPrevious(string $s): string {
new $a($b);',
'error_message' => 'TaintedCallable',
],
'urlencode' => [
/**
* urlencode() should only prevent html & has_quotes taints
* All other taint types should be unaffected.
* We arbitrarily chose system() to test this.
*/
'code' => '<?php
system(urlencode($_GET["bad"]));
',
'error_message' => 'TaintedShell'
]
];
}

Expand Down

0 comments on commit 4dc969b

Please sign in to comment.