note 111218 deleted from function.setlocale by cmb

From: Date: Sun, 10 Nov 2019 12:26:07 +0000
Subject: note 111218 deleted from function.setlocale by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212966@lists.php.net to get a copy of this message
Note Submitter: c dot madmax at gmail dot com ---- <?php // the last foldername only contains a german umlaut (lower a with two dots = \xE4 in ISO-8859-1) $path = "/home/madmax/photos_from_the_last_10_years/\xE4" // php escapeshellarg remove characters (depends on locale settings) // the following example will delete /home/madmax/photos_from_the_last_10_years/ // instead of /home/madmax/photos_from_the_last_10_years/ä shell_exec(sprintf('rm -fr %s' escapeshellarg($path))); // dear php developers, how stupid is that? // I tell you: it is very very stupid! The problem exists since years and nothing happens (see bug #54391) // this code will not remove all your photos of the last 10 years :) function binary_safe_escapeshellarg_that_is_not_totally_buggy_and_do_not_remove_f___ing_characters($string) { return(@sprintf("'%s'", @strtr($string, Array("\x27" => "\x27\x5C\x27\x27")))); }; // delete /home/madmax/photos_from_the_last_10_years/ä // and not /home/madmax/photos_from_the_last_10_years/ shell_exec(sprintf('rm -fr %s' binary_safe_escapeshellarg_that_is_not_totally_buggy_and_do_not_remove_f___ing_characters($path))); // binary safe! ?>

« previous php.notes (#212966) next »