Wenn man sich Product.php
classe Definition:
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
Sie sehen, dass es isCleanHtml
Prüfung verwendet. Hier
ist der isCleanHtml
Validator:
/**
* Check for HTML field validity (no XSS please !)
*
* @param string $html HTML field to validate
* @return bool Validity is ok or not
*/
public static function isCleanHtml($html, $allow_iframe = false)
{
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
$events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
$events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
$events .= '|onselectstart|onstart|onstop';
if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) {
return false;
}
if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) {
return false;
}
return true;
}
Sie können den Test auf <script>
Elemente sehen.
Jetzt wäre die Lösung Product.php
classe und entfernen Sie die Validierung auf Produktbeschreibungen außer Kraft zu setzen sein.
Erstellen Sie die Datei (oder aktualisieren) /override/classes/Product.php
:
<?php
class Product extends ProductCore
{
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
{
// Here we remove script validation on description_short field
unset(static::$definition['fields']['description_short']['validate']);
parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
}
}
Wenn Sie diese Datei erstellen, werden Sie /cache/class_index.php
so löschen, dass Prestashop diese Überschreibung berücksichtigt.
Getestet und funktioniert.
Vielen Dank. – javgoji