[SPIP] ~v3.2.4-->v3.2.5
[lhc/web/www.git] / www / ecrire / inc / headers.php
index 8b18633..0146614 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************************\
  *  SPIP, Systeme de publication pour l'internet                           *
  *                                                                         *
- *  Copyright (c) 2001-2017                                                *
+ *  Copyright (c) 2001-2019                                                *
  *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  *                                                                         *
  *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
@@ -59,6 +59,10 @@ function redirige_par_entete($url, $equiv = '', $status = 302) {
 
        // ne pas laisser passer n'importe quoi dans l'url
        $url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $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))
@@ -69,8 +73,12 @@ function redirige_par_entete($url, $equiv = '', $status = 302) {
 
        // Il n'y a que sous Apache que setcookie puis redirection fonctionne
        include_spip('inc/cookie');
-       if ((!$equiv and !spip_cookie_envoye()) or ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'],
-                                       6) == 0) or defined('_SERVER_APACHE'))
+       if ((!$equiv and !spip_cookie_envoye()) or (
+                          (strncmp("Apache", $_SERVER['SERVER_SOFTWARE'], 6) == 0)
+                       or (stripos($_SERVER['SERVER_SIGNATURE'], 'Apache') !== false)
+                       or function_exists('apache_getenv')
+                       or defined('_SERVER_APACHE')
+               )
        ) {
                @header("Location: " . $url);
                $equiv = "";