N°3565 - Migrate backoffice pages to new UIBlock system : Setup (fix bad escaping)

This commit is contained in:
Eric
2021-02-08 11:58:52 +01:00
parent 96faad7539
commit 0c7925cdfb

View File

@@ -132,7 +132,7 @@ class Extension
// Filter to sanitize a string (escape ')
// Usage in twig: {{ 'string'|escape_for_js_string }}
$oTwigEnv->addFilter(new Twig_SimpleFilter('escape_for_js_string', function ($sString) {
return str_replace(["\n"], [" "], htmlentities($sString, ENT_QUOTES, 'UTF-8'));
return str_replace(["'", '"', "\n"], ["\\'", "\\\"", " "], $sString);
})
);