plausichecks fehlertext: check number of parameters before calling vsprintf

This commit is contained in:
KarpAlex
2022-10-05 14:07:29 +02:00
parent c31ab4874d
commit edd310351b
2 changed files with 18 additions and 2 deletions
@@ -78,7 +78,15 @@ class Plausichecks extends Auth_Controller
if (hasData($fehlerRes))
{
$fehlerText = getData($fehlerRes)[0]->fehlertext;
$fehlerText = isEmptyArray($fehlertext_params) ? $fehlerText : vsprintf($fehlerText, $fehlertext_params);
if (!isEmptyArray($fehlertext_params))
{
if (count($fehlertext_params) != substr_count($fehlerText, '%s'))
$this->terminateWithJsonError('Wrong number of parameters for Fehlertext, fehler_kurzbz ' . $fehler_kurzbz);
$fehlerText = vsprintf($fehlerText, $fehlertext_params);
}
if (isset($person_id)) $fehlerText .= "; person_id: $person_id";
if (isset($oe_kurzbz)) $fehlerText .= "; oe_kurzbz: $oe_kurzbz";
$issueTexts[$fehler_kurzbz][] = $fehlerText;