Formation Prestashop intégrateur: Nouveautés de la 1.7. / Echappement des variables

Vous êtes ici : Accueil / Prestashop intégrateur / Nouveautés de la 1.7. / Echappement des variables


Echappement des variables

Sur PrestaShop 1.6 et sur PrestaShop 1.7 back-office Legacy

Exemple de code PHP :

$var = '<b>Hello</b>';
$smarty->assign('var', $var);

Exemple d'instruction smarty :

{$var}                         {* Hello in Bold (XSS) *}
{$var|escape:"html":"utf-8"}   {* <b>Hello</b> *}
{$var|cleanHtml}               {* Hello in Bold (Or nothing if js) *}

Sur PrestaShop 1.7 front-office

Exemple de code PHP :

$var = '<b>Hello</b>';
$smarty->assign('var', $var);

Exemple d'instruction smarty :

{$var}             {* <b>Hello</b> *}
{$var nofilter}    {* Hello in Bold (XSS) *}
{$var|cleanHtml nofilter}    {* Hello in Bold *}