Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
commit
c90ba4c406
11 files changed
+63
-23
No files matched your search
+1
-1
@@ -53,7 +53,7 @@ class CMSCore extends ObjectModel
|
|||||||
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
||||||
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
|
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
|
||||||
'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 3999999999999),
|
'content' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 3999999999999),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class CategoryCore extends ObjectModel
|
|||||||
// Lang fields
|
// Lang fields
|
||||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
|
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64),
|
||||||
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
|
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64),
|
||||||
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
|
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||||
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
||||||
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
|
|||||||
+4
-4
@@ -64,10 +64,10 @@ class HookCore extends ObjectModel
|
|||||||
'primary' => 'id_hook',
|
'primary' => 'id_hook',
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 64),
|
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isHookName', 'required' => true, 'size' => 64),
|
||||||
'title' => array('type' => self::TYPE_STRING),
|
'title' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
|
||||||
'description' => array('type' => self::TYPE_HTML),
|
'description' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'),
|
||||||
'position' => array('type' => self::TYPE_BOOL),
|
'position' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'live_edit' => array('type' => self::TYPE_BOOL),
|
'live_edit' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ class ManufacturerCore extends ObjectModel
|
|||||||
'date_upd' => array('type' => self::TYPE_DATE),
|
'date_upd' => array('type' => self::TYPE_DATE),
|
||||||
|
|
||||||
// Lang fields
|
// Lang fields
|
||||||
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
|
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||||
'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString', 'size' => 254),
|
'short_description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'size' => 254),
|
||||||
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
||||||
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'),
|
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName'),
|
||||||
|
|||||||
+17
-2
@@ -939,8 +939,23 @@ abstract class ObjectModelCore
|
|||||||
if (!method_exists('Validate', $data['validate']))
|
if (!method_exists('Validate', $data['validate']))
|
||||||
throw new PrestaShopException('Validation function not found. '.$data['validate']);
|
throw new PrestaShopException('Validation function not found. '.$data['validate']);
|
||||||
|
|
||||||
if (!empty($value) && !call_user_func(array('Validate', $data['validate']), $value))
|
if (!empty($value))
|
||||||
return 'Property '.get_class($this).'->'.$field.' is not valid';
|
{
|
||||||
|
$res = true;
|
||||||
|
if (Tools::strtolower($data['validate']) == 'isCleanHtml')
|
||||||
|
{
|
||||||
|
d('in');
|
||||||
|
if (!call_user_func(array('Validate', $data['validate']), $value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
|
||||||
|
$res = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!call_user_func(array('Validate', $data['validate']), $value))
|
||||||
|
$res = false;
|
||||||
|
}
|
||||||
|
if (!$res)
|
||||||
|
return 'Property '.get_class($this).'->'.$field.' is not valid';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+2
-2
@@ -297,8 +297,8 @@ class ProductCore extends ObjectModel
|
|||||||
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128),
|
||||||
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
|
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
|
||||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
|
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
|
||||||
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
|
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||||
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isString'),
|
'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
|
||||||
'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||||
'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255),
|
'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255),
|
||||||
),
|
),
|
||||||
|
|||||||
+10
-3
@@ -380,7 +380,7 @@ class ValidateCore
|
|||||||
*/
|
*/
|
||||||
public static function isGenericName($name)
|
public static function isGenericName($name)
|
||||||
{
|
{
|
||||||
return empty($name) || preg_match('/^[^<>=#{}]*$/u', $name);
|
return empty($name) || preg_match('/^[^<>={}]*$/u', $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -389,7 +389,7 @@ class ValidateCore
|
|||||||
* @param string $html HTML field to validate
|
* @param string $html HTML field to validate
|
||||||
* @return boolean Validity is ok or not
|
* @return boolean Validity is ok or not
|
||||||
*/
|
*/
|
||||||
public static function isCleanHtml($html)
|
public static function isCleanHtml($html, $allow_iframe = false)
|
||||||
{
|
{
|
||||||
$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
|
$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 .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
|
||||||
@@ -398,7 +398,14 @@ class ValidateCore
|
|||||||
$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
|
$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 .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
|
||||||
$events .= '|onselectstart|onstart|onstop';
|
$events .= '|onselectstart|onstart|onstop';
|
||||||
return (!preg_match('/<[ \t\n]*script/ims', $html) && !preg_match('/('.$events.')[ \t\n]*=/ims', $html) && !preg_match('/.*script\:/ims', $html) && !preg_match('/<[ \t\n]*i?frame/ims', $html));
|
|
||||||
|
if (preg_match('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!$allow_iframe && preg_match('/<[ \t\n]*(i?frame|form|input|embed|object)/ims', $html))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -433,10 +433,10 @@ class AdminCountriesControllerCore extends AdminController
|
|||||||
|
|
||||||
public function processStatus()
|
public function processStatus()
|
||||||
{
|
{
|
||||||
$return = parent::processStatus();
|
parent::processStatus();
|
||||||
if (Validate::isLoadedObject($object = $this->loadObject()) && $object->active == 1)
|
if (Validate::isLoadedObject($object = $this->loadObject()) && $object->active == 1)
|
||||||
$return &= Country::addModuleRestrictions(array(), array(array('id_country' => $object->id)), array());
|
return Country::addModuleRestrictions(array(), array(array('id_country' => $object->id)), array());
|
||||||
return $return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processBulkStatusSelection($way)
|
public function processBulkStatusSelection($way)
|
||||||
|
|||||||
@@ -95,6 +95,14 @@ class AdminPreferencesControllerCore extends AdminController
|
|||||||
'default' => '0',
|
'default' => '0',
|
||||||
'visibility' => Shop::CONTEXT_ALL
|
'visibility' => Shop::CONTEXT_ALL
|
||||||
),
|
),
|
||||||
|
'PS_ALLOW_HTML_IFRAME' => array(
|
||||||
|
'title' => $this->l('Allow iframes on html fields'),
|
||||||
|
'desc' => $this->l('Allow iframes on fields like product description. We recommend that you leave this option disabled'),
|
||||||
|
'validation' => 'isBool',
|
||||||
|
'cast' => 'intval',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => '0'
|
||||||
|
),
|
||||||
'PS_PRICE_ROUND_MODE' => array(
|
'PS_PRICE_ROUND_MODE' => array(
|
||||||
'title' => $this->l('Round mode'),
|
'title' => $this->l('Round mode'),
|
||||||
'desc' => $this->l('You can choose how to round prices: Always round superior, always round inferior or classic rounding.'),
|
'desc' => $this->l('You can choose how to round prices: Always round superior, always round inferior or classic rounding.'),
|
||||||
|
|||||||
@@ -2058,17 +2058,28 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
// Check fields validity
|
// Check fields validity
|
||||||
foreach ($rules['validate'] as $field => $function)
|
foreach ($rules['validate'] as $field => $function)
|
||||||
if ($this->isProductFieldUpdated($field) && ($value = Tools::getValue($field)))
|
if ($this->isProductFieldUpdated($field) && ($value = Tools::getValue($field)))
|
||||||
if (!Validate::$function($value))
|
{
|
||||||
|
$res = true;
|
||||||
|
if (Tools::strtolower($function) == 'isCleanHtml')
|
||||||
|
{
|
||||||
|
if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
|
||||||
|
$res = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (!Validate::$function($value))
|
||||||
|
$res = false;
|
||||||
|
|
||||||
|
if (!$res)
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = sprintf(
|
||||||
Tools::displayError('The %s field is invalid.'),
|
Tools::displayError('The %s field is invalid.'),
|
||||||
call_user_func(array($className, 'displayFieldName'), $field, $className)
|
call_user_func(array($className, 'displayFieldName'), $field, $className)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
// Check multilingual fields validity
|
// Check multilingual fields validity
|
||||||
foreach ($rules['validateLang'] as $fieldLang => $function)
|
foreach ($rules['validateLang'] as $fieldLang => $function)
|
||||||
foreach ($languages as $language)
|
foreach ($languages as $language)
|
||||||
if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])))
|
if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue($fieldLang.'_'.$language['id_lang'])))
|
||||||
if (!Validate::$function($value))
|
if (!Validate::$function($value, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')))
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = sprintf(
|
||||||
Tools::displayError('The %1$s field (%2$s) is invalid.'),
|
Tools::displayError('The %1$s field (%2$s) is invalid.'),
|
||||||
call_user_func(array($className, 'displayFieldName'), $fieldLang, $className),
|
call_user_func(array($className, 'displayFieldName'), $fieldLang, $className),
|
||||||
|
|||||||
@@ -649,8 +649,7 @@ class ReferralProgram extends Module
|
|||||||
{
|
{
|
||||||
$cartRule = new CartRule((int)$referralprogram->id_cart_rule_sponsor);
|
$cartRule = new CartRule((int)$referralprogram->id_cart_rule_sponsor);
|
||||||
$currency = new Currency((int)$order->id_currency);
|
$currency = new Currency((int)$order->id_currency);
|
||||||
$discount_display = ReferralProgram::displayDiscount($cartRule->reduction_percent ? $cartRule->reduction_percent : $cartRule->reduction_amount, $cartRule->reduction_percent ? 1 : 2, $currency);
|
$discount_display = ReferralProgram::displayDiscount( (float) $cartRule->reduction_percent ? (float) $cartRule->reduction_percent : (int) $cartRule->reduction_amount, (float) $cartRule->reduction_percent ? 1 : 2, $currency); $data = array('{sponsored_firstname}' => $customer->firstname, '{sponsored_lastname}' => $customer->lastname, '{discount_display}' => $discount_display, '{discount_name}' => $cartRule->code);
|
||||||
$data = array('{sponsored_firstname}' => $customer->firstname, '{sponsored_lastname}' => $customer->lastname, '{discount_display}' => $discount_display, '{discount_name}' => $cartRule->code);
|
|
||||||
Mail::Send((int)$order->id_lang, 'referralprogram-congratulations', Mail::l('Congratulations!', (int)$order->id_lang), $data, $sponsor->email, $sponsor->firstname.' '.$sponsor->lastname, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
|
Mail::Send((int)$order->id_lang, 'referralprogram-congratulations', Mail::l('Congratulations!', (int)$order->id_lang), $data, $sponsor->email, $sponsor->firstname.' '.$sponsor->lastname, strval(Configuration::get('PS_SHOP_EMAIL')), strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, dirname(__FILE__).'/mails/');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user