untaint

(PECL taint >=0.1.0)

untaintRemove the taint mark from strings

Beschreibung

function untaint(string &$string, string &...$strings): bool

Clears the taint mark on the given strings.

The mark is stored on the string itself, not on the variable, so this clears it for every variable sharing the same string at once. Use it to whitelist values you have validated yourself, for example after a strict allow-list check.

Parameter-Liste

string

A variable holding the string to clean.

strings

Further variables to clean.

Rückgabewerte

Always returns true. When taint.enable is off, the function does nothing and still returns true.

Beispiele

Beispiel #1 untaint() example

<?php
$id = "42";
taint($id);
if (preg_match('/^\d+$/', $id)) {
    // strictly validated as digits: safe to trust
    untaint($id);
}
var_dump(is_tainted($id));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

bool(false)

Anmerkungen

Hinweis:

Only string values can carry the mark; passing a non-string is a no-op.

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.