Skip to content

Commit

Permalink
Merge pull request PrestaShop#7087 from mickaelandrieu/fixed-1841
Browse files Browse the repository at this point in the history
Protect translations display against XSS injections
  • Loading branch information
Maxime Biloé authored Dec 5, 2016
2 parents 93da545 + c80f23c commit 698a399
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions classes/module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3102,6 +3102,7 @@ public function getTranslator()

protected function trans($id, array $parameters = array(), $domain = null, $locale = null)
{
$parameters['legacy'] = 'htmlspecialchars';
return $this->getTranslator()->trans($id, $parameters, $domain, $locale);
}
}
Expand Down
2 changes: 1 addition & 1 deletion config/smartyadmin.config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function smartyTranslate($params, &$smarty)
$isInModule = isset($params['mod']) && !empty($params['mod']);
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : array();

if ($htmlEntities || $addSlashes) {
if (($htmlEntities || $addSlashes) && is_array($sprintf) && !empty($sprintf)) {
$sprintf['legacy'] = $htmlEntities ? 'htmlspecialchars': 'addslashes';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public function trans($id, array $parameters = array(), $domain = null, $locale

if (!$this->isSprintfString($id) || empty($parameters)) {
$translated = parent::trans($id, $parameters, $domain, $locale);
if (isset($parameters['legacy'])) {
$translated = call_user_func($parameters['legacy'],$translated);
}
}else {
$parameters['legacy'] = 'htmlspecialchars';
$translated = call_user_func($parameters['legacy'], $translated);
} else {
$translated = vsprintf(parent::trans($id, array(), $domain, $locale), $parameters);
}

Expand Down

0 comments on commit 698a399

Please sign in to comment.