// ne pas laisser passer n'importe quoi dans l'url
$url = str_replace(array('<', '"'), array('<', '"'), $url);
+ $url = str_replace(array("\r", "\n", ' '), array('%0D', '%0A', '%20'), $url);
+ while (strpos($url, '%0A') !== false) {
+ $url = str_replace('%0A', '', $url);
+ }
// interdire les url inline avec des pseudo-protocoles :
if (
(preg_match(",data:,i", $url) and preg_match("/base64\s*,/i", $url))
*
* Ainsi `http_status(301)` enverra le message `301 Moved Permanently`.
*
- * @link http://php.net/manual/fr/function.header.php Fonction header() de PHP utilisée ici
+ * @link https://www.php.net/manual/fr/function.http-response-code.php
+ * @uses http_response_code()
*
* @param int $status
* Code d'erreur
**/
function http_status($status) {
-
- static $status_string = array(
- 200 => '200 OK',
- 204 => '204 No Content',
- 301 => '301 Moved Permanently',
- 302 => '302 Found',
- 304 => '304 Not Modified',
- 401 => '401 Unauthorized',
- 403 => '403 Forbidden',
- 404 => '404 Not Found',
- 503 => '503 Service Unavailable'
- );
-
- if (!empty($GLOBALS['REDIRECT_STATUS']) && $GLOBALS['REDIRECT_STATUS'] == $status) {
- return;
- }
-
- $php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
- if ($php_cgi) {
- header("Status: " . $status_string[$status]);
- } else {
- header("HTTP/1.0 " . $status_string[$status]);
- }
+ http_response_code($status);
}
// Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache