Disabled Auto Escape (ARCH7134)
Ce contenu n’est pas encore disponible dans votre langue.
Key php.security.disabled-auto-escape · Severity warning · Category security · CWE CWE-79
Turning off auto-escaping in a template engine such as Twig removes the default XSS protection for all rendered output. Writing untrusted data raw into HTML causes cross-site scripting.
Incorrect
Section titled “Incorrect”<?php$twig = new \Twig\Environment($loader, [ 'autoescape' => false, // all output unescaped]);echo $twig->render('profile.html', ['bio' => $userBio]);Correct
Section titled “Correct”<?php$twig = new \Twig\Environment($loader, [ 'autoescape' => 'html',]);echo $twig->render('profile.html', ['bio' => $userBio]);Keep auto-escaping enabled globally; use a local |raw only for genuinely required, sanitized fragments.