2016-06-20 3 views
2

私はきれいなPrestashop 1.6.1.6のインストールがあります。私はJavascriptを簡単な説明製品に入れました。Prestashop 1.6.1.6無効な短い説明javascriptを使用した製品

私は私の製品PrestaShopのを保存し、エラーを私に示しています

Invalid short Description

私は私の製品説明にテキストを保存エラーがありません。

PrestaShopの設定:

  • HTML清浄=いいえ
  • IフレームHTML = YES
  • 簡単な説明長い= 0

私は古いPrestaShopのバージョンのような短い説明でJavaScriptを追加することができますどのように?

Product error message

答えて

2

あなたはProduct.phpクラッセの定義を見てみると:

'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 

あなたはそれがisCleanHtmlバリデータを使用していることがわかります。ここで

isCleanHtmlバリです:

/** 
* 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; 
} 

あなたは<script>要素でテストを見ることができます。


今ソリューションはProduct.phpクラッセをオーバーライドして、製品の説明の検証を取り除くことであろう。

は、ファイルを作成(または更新)/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); 
    } 
} 

あなたはこのファイルを作成した場合、あなたはPrestaShopのは、アカウントにこのオーバーライドをとるように/cache/class_index.phpを削除する必要があります。

テスト済みです。

+0

ありがとうございました。 – javgoji

関連する問題