mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Fix #4620 - reconciled literal strings cannot carry taints
This commit is contained in:
parent
20c78ae29b
commit
7c02fa76d1
@ -309,7 +309,8 @@ class Reconciler
|
||||
}
|
||||
|
||||
if (($statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\TaintFlowGraph
|
||||
&& (!$result_type->hasScalarType()) || $result_type->hasString())
|
||||
&& (!$result_type->hasScalarType())
|
||||
|| ($result_type->hasString() && !$result_type->hasLiteralString()))
|
||||
|| $statements_analyzer->data_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
|
||||
) {
|
||||
if ($before_adjustment && $before_adjustment->parent_nodes) {
|
||||
|
@ -544,6 +544,19 @@ class TaintTest extends TestCase
|
||||
$a = new A("bar");
|
||||
echo $a->getTaint();',
|
||||
],
|
||||
'literalStringCannotCarryTaint' => [
|
||||
'<?php
|
||||
$file = $_GET["foo"];
|
||||
|
||||
if ($file !== "") {
|
||||
/**
|
||||
* @psalm-taint-escape input
|
||||
*/
|
||||
$file = basename($file);
|
||||
}
|
||||
|
||||
echo $file;'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user