Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed taints to pass through urlencode() #8848

Merged
merged 1 commit into from Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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