Skip to content

Commit

Permalink
Fix XSS in Conditions tab of Pricing Rules (#14963)
Browse files Browse the repository at this point in the history
* Fix error when the date field is null

* Fix xss in date field in pricing-ecommerce

* Fix date input
  • Loading branch information
aryaantony92 committed Apr 19, 2023
1 parent 7a79939 commit a449155
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Expand Up @@ -92,8 +92,8 @@ public function toJSON()
{
return json_encode([
'type' => 'DateRange',
'starting' => $this->getStarting()->format('d.m.Y'),
'ending' => $this->getEnding()->format('d.m.Y'),
'starting' => $this->getStarting()?->format('d.m.Y'),
'ending' => $this->getEnding()?->format('d.m.Y'),
]);
}

Expand All @@ -107,13 +107,17 @@ public function fromJSON($string)
$json = json_decode($string);

$starting = \DateTime::createFromFormat('d.m.Y', $json->starting, new DateTimeZone('UTC'));
$starting->setTime(0, 0, 0);

if($starting instanceof \DateTime) {
$starting->setTime(0, 0, 0);
$this->setStarting($starting);
}
$ending = \DateTime::createFromFormat('d.m.Y', $json->ending, new DateTimeZone('UTC'));
$ending->setTime(23, 59, 59);

$this->setStarting($starting);
$this->setEnding($ending);
if($ending instanceof \DateTime) {
$ending->setTime(23, 59, 59);
$this->setEnding($ending);
}


return $this;
}
Expand Down
Expand Up @@ -706,15 +706,25 @@ pimcore.bundle.EcommerceFramework.pricing.conditions = {
format: 'd.m.Y',
altFormats: 'U',
value: data.starting,
width: 400
width: 400,
onChange: function (value) {
if (Ext.String.hasHtmlCharacters(value)) {
this.setValue(null);
}
},
},{
xtype:'datefield',
fieldLabel: t("to"),
name: "ending",
format: 'd.m.Y',
altFormats: 'U',
value: data.ending,
width: 400
width: 400,
onChange: function (value) {
if (Ext.String.hasHtmlCharacters(value)) {
this.setValue(null);
}
},
}],
listeners: {

Expand Down

0 comments on commit a449155

Please sign in to comment.