diff --git a/lib/variables.php b/lib/variables.php index 93f1a9c..cbc4959 100644 --- a/lib/variables.php +++ b/lib/variables.php @@ -61,6 +61,14 @@ if (substr($_SERVER["REQUEST_URI"],0,4)=="/ru/") $_REQUEST["idioma"]="ru"; if (substr($_SERVER["REQUEST_URI"],0,4)=="/ni/") $_REQUEST["idioma"]="ni"; + // Seguridad: el idioma puede llegar crudo por ?idioma= (la query string se + // reenvia entera a slug.php via .htaccess). Se refleja sin escapar en varias + // plantillas (RUTA_RAIZ/ROOT, lang="...", vars JS) -> XSS reflejado. Se valida + // contra un allowlist antes de definir constantes y renderizar: cualquier + // valor que no sea un idioma conocido se descarta. + $__idiomasValidos = array("en","es","de","fr","pt","se","cat","it","ko","ch","nu","ru","ni"); + if (!in_array(@$_REQUEST["idioma"], $__idiomasValidos, true)) $_REQUEST["idioma"] = ""; + if (@$_REQUEST["idioma"]) define("RUTA_RAIZ","/".$_REQUEST["idioma"]); else define("RUTA_RAIZ",""); if (@$_REQUEST["idioma"]) define("ROOT","/".$_REQUEST["idioma"]); else define("ROOT",""); diff --git a/template/layout_templates/footer.tpl b/template/layout_templates/footer.tpl index 7fb2c87..a1cfeae 100644 --- a/template/layout_templates/footer.tpl +++ b/template/layout_templates/footer.tpl @@ -35,7 +35,7 @@ if (!@$_REQUEST["viewAMP"]){ Resource::link('/css/cesta.css', true); ?>