Skip to content

Commit 1c9ebbe

Browse files
author
Igor Melnikov
committed
Merge remote-tracking branch 'upstream/develop' into MAGETWO-56133-unsecure-functions
2 parents 17c5bef + 2f9032b commit 1c9ebbe

File tree

64 files changed

+1176
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1176
-313
lines changed

app/code/Magento/Authorizenet/view/adminhtml/templates/directpost/info.phtml

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
3535
</label>
3636
<div class="admin__field-control">
3737
<select id="<?php /* @noEscape */ echo $code; ?>_cc_type" name="payment[cc_type]"
38-
class="required-entry validate-cc-type-select admin__control-select">
39-
<option value=""></option>
38+
class="admin__control-select"
39+
data-validate="{
40+
'required':true,
41+
'validate-cc-type-select':'#<?php /* @noEscape */ echo $code; ?>_cc_number'
42+
}">
43+
<option value=""><?php echo $block->escapeHtml(__('Please Select')); ?></option>
4044
<?php foreach ($block->getCcAvailableTypes() as $typeCode => $typeName): ?>
4145
<option value="<?php echo $block->escapeHtml($typeCode); ?>"
4246
<?php if ($typeCode == $ccType): ?>selected="selected"<?php endif; ?>>
@@ -46,27 +50,37 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
4650
</select>
4751
</div>
4852
</div>
53+
4954
<div class="admin__field _required">
5055
<label for="<?php /* @noEscape */ echo $code; ?>_cc_number" class="admin__field-label">
5156
<span><?php echo $block->escapeHtml(__('Credit Card Number')); ?></span>
5257
</label>
53-
5458
<div class="admin__field-control">
5559
<input type="text" id="<?php /* @noEscape */ echo $code; ?>_cc_number"
5660
name="payment[cc_number]"
57-
class="input-text required-entry validate-cc-number admin__control-text"
61+
data-validate="{
62+
'required-number':true,
63+
'validate-cc-number':'#<?php /* @noEscape */ echo $code; ?>_cc_type',
64+
'validate-cc-type':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
65+
}"
66+
class="admin__control-text"
5867
value="<?php /* @noEscape */ echo $block->getInfoData('cc_number'); ?>"/>
5968
</div>
6069
</div>
61-
<div class="admin__field _required">
70+
71+
<div class="admin__field _required field-date" id="<?php /* @noEscape */ echo $code; ?>_cc_type_exp_div">
6272
<label for="<?php /* @noEscape */ echo $code; ?>_expiration" class="admin__field-label">
6373
<span><?php echo $block->escapeHtml(__('Expiration Date')); ?></span>
6474
</label>
6575

6676
<div class="admin__field-control">
6777
<select id="<?php /* @noEscape */ echo $code; ?>_expiration"
6878
name="payment[cc_exp_month]"
69-
class="validate-cc-exp required-entry admin__control-select admin__control-select-month">
79+
class="admin__control-select admin__control-select-month"
80+
data-validate="{
81+
'required':true,
82+
'validate-cc-exp':'#<?php /* @noEscape */ echo $code; ?>_expiration_yr'
83+
}">
7084
<?php foreach ($block->getCcMonths() as $k => $v): ?>
7185
<option value="<?php echo $block->escapeHtml($k); ?>"
7286
<?php if ($k == $ccExpMonth): ?>selected="selected"<?php endif; ?>>
@@ -76,7 +90,9 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
7690
</select>
7791
<select id="<?php /* @noEscape */ echo $code; ?>_expiration_yr"
7892
name="payment[cc_exp_year]"
79-
class="required-entry admin__control-select admin__control-select-year">
93+
class="admin__control-select admin__control-select-year"
94+
data-container="<?php /* @noEscape */ echo $code; ?>-cc-year"
95+
data-validate="{required:true}">
8096
<?php foreach ($block->getCcYears() as $k => $v): ?>
8197
<option value="<?php /* @noEscape */ echo $k ? $block->escapeHtml($k) : ''; ?>"
8298
<?php if ($k == $ccExpYear): ?>selected="selected"<?php endif; ?>>
@@ -86,17 +102,27 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
86102
</select>
87103
</div>
88104
</div>
105+
89106
<?php if ($block->hasVerification()): ?>
90-
<div class="admin__field _required">
91-
<label for="<?php /* @noEscape */ echo $code; ?>_cc_cid">
107+
<div class="admin__field _required field-cvv">
108+
<label class="admin__field-label"
109+
for="<?php /* @noEscape */ echo $code; ?>_cc_cid"
110+
id="<?php /* @noEscape */ echo $code; ?>_cc_type_cvv_div">
92111
<span><?php echo $block->escapeHtml(__('Card Verification Number')); ?></span>
93112
</label>
94113

95114
<div class="admin__field-control">
96115
<input type="text"
97-
class="required-entry input-text validate-cc-cvn admin__control-text"
116+
data-container="<?php /* @noEscape */ echo $code; ?>-cc-cvv"
117+
title="<?php echo $block->escapeHtml(__('Card Verification Number')); ?>"
118+
class="admin__control-text cvv"
98119
id="<?php /* @noEscape */ echo $code; ?>_cc_cid" name="payment[cc_cid]"
99-
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"/>
120+
value="<?php /* @noEscape */ echo $block->getInfoData('cc_cid') ?>"
121+
data-validate="{
122+
'required-number':true,
123+
'validate-cc-cvn':'#<?php /* @noEscape */ echo $code; ?>_cc_type'
124+
}"
125+
autocomplete="off"/>
100126
</div>
101127
</div>
102128
<?php endif; ?>
@@ -105,7 +131,7 @@ $ccExpYear = $block->getInfoData('cc_exp_year');
105131
require([
106132
'prototype',
107133
'Magento_Sales/order/create/scripts',
108-
"Magento_Sales/order/create/form",
134+
'Magento_Sales/order/create/form',
109135
'Magento_Authorizenet/js/direct-post'
110136
], function(){
111137

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ public function getPostDataRemove($product)
231231
$data = [
232232
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
233233
'product' => $product->getId(),
234+
'confirmation' => true,
235+
'confirmationMessage' => __('Are you sure you want to remove this item from your Compare Products list?')
234236
];
235237
return $this->postHelper->getPostData($this->getRemoveUrl(), $data);
236238
}
@@ -254,6 +256,8 @@ public function getPostDataClearList()
254256
{
255257
$params = [
256258
\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => '',
259+
'confirmation' => true,
260+
'confirmationMessage' => __('Are you sure you want to remove all items from your Compare Products list?'),
257261
];
258262
return $this->postHelper->getPostData($this->getClearListUrl(), $params);
259263
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class Value extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
3333
*/
3434
protected $_config;
3535

36+
/**
37+
* @var \Magento\Framework\Locale\FormatInterface
38+
*/
39+
private $localeFormat;
40+
3641
/**
3742
* Class constructor
3843
*
@@ -91,8 +96,9 @@ protected function _afterSave(\Magento\Framework\Model\AbstractModel $object)
9196
protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $object)
9297
{
9398
$priceTable = $this->getTable('catalog_product_option_type_price');
99+
$formattedPrice = $this->getLocaleFormatter()->getNumber($object->getPrice());
94100

95-
$price = (double)sprintf('%F', $object->getPrice());
101+
$price = (double)sprintf('%F', $formattedPrice);
96102
$priceType = $object->getPriceType();
97103

98104
if ($object->getPrice() && $priceType) {
@@ -410,4 +416,19 @@ public function duplicate(\Magento\Catalog\Model\Product\Option\Value $object, $
410416

411417
return $object;
412418
}
419+
420+
/**
421+
* Get FormatInterface to convert price from string to number format
422+
*
423+
* @return \Magento\Framework\Locale\FormatInterface
424+
* @deprecated
425+
*/
426+
private function getLocaleFormatter()
427+
{
428+
if ($this->localeFormat === null) {
429+
$this->localeFormat = \Magento\Framework\App\ObjectManager::getInstance()
430+
->get(\Magento\Framework\Locale\FormatInterface::class);
431+
}
432+
return $this->localeFormat;
433+
}
413434
}

app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ public function testGetPostDataRemove()
115115
$removeUrl = 'catalog/product_compare/remove';
116116
$postParams = [
117117
Action::PARAM_NAME_URL_ENCODED => '',
118-
'product' => $productId
118+
'product' => $productId,
119+
'confirmation' => true,
120+
'confirmationMessage' => __('Are you sure you want to remove this item from your Compare Products list?'),
119121
];
120122

121123
//Verification
@@ -156,7 +158,9 @@ public function testGetPostDataClearList()
156158
//Data
157159
$clearUrl = 'catalog/product_compare/clear';
158160
$postParams = [
159-
Action::PARAM_NAME_URL_ENCODED => ''
161+
Action::PARAM_NAME_URL_ENCODED => '',
162+
'confirmation' => true,
163+
'confirmationMessage' => __('Are you sure you want to remove all items from your Compare Products list?'),
160164
];
161165

162166
//Verification

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -831,20 +831,6 @@ private function getStatusStockProviderData($extensionAttributesMock)
831831
];
832832
}
833833

834-
public function testStatusAfterLoad()
835-
{
836-
$this->resource->expects($this->once())->method('load')->with($this->model, 1, null);
837-
$this->eventManagerMock->expects($this->exactly(4))->method('dispatch');
838-
$this->model->load(1);
839-
$this->assertEquals(
840-
Status::STATUS_ENABLED,
841-
$this->model->getData(\Magento\Catalog\Model\Product::STATUS)
842-
);
843-
$this->assertFalse($this->model->hasDataChanges());
844-
$this->model->setStatus(Status::STATUS_DISABLED);
845-
$this->assertTrue($this->model->hasDataChanges());
846-
}
847-
848834
/**
849835
* Test retrieving price Info
850836
*/

app/code/Magento/Catalog/view/adminhtml/web/js/components/import-handler.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55

66
define([
7+
'underscore',
78
'Magento_Ui/js/form/element/textarea'
8-
], function (Textarea) {
9+
], function (_, Textarea) {
910
'use strict';
1011

1112
return Textarea.extend({
@@ -123,24 +124,21 @@ define([
123124
* Update field value, if it's allowed
124125
*/
125126
updateValue: function () {
126-
var str = this.mask,
127+
var str = this.mask || '',
127128
nonEmptyValueFlag = false,
128-
placeholder,
129-
property,
130129
tmpElement;
131130

132131
if (!this.allowImport) {
133132
return;
134133
}
135134

136-
for (property in this.values) {
137-
if (this.values.hasOwnProperty(property)) {
138-
placeholder = '';
139-
placeholder = placeholder.concat('{{', property, '}}');
140-
str = str.replace(placeholder, this.values[property]);
141-
nonEmptyValueFlag = nonEmptyValueFlag || !!this.values[property];
142-
}
135+
if (str) {
136+
_.each(this.values, function (propertyValue, propertyName) {
137+
str = str.replace('{{' + propertyName + '}}', propertyValue);
138+
nonEmptyValueFlag = nonEmptyValueFlag || !!propertyValue;
139+
});
143140
}
141+
144142
// strip tags
145143
tmpElement = document.createElement('div');
146144
tmpElement.innerHTML = str;

app/code/Magento/Catalog/view/frontend/requirejs-config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
var config = {
77
map: {
88
'*': {
9-
compareItems: 'Magento_Catalog/js/compare',
109
compareList: 'Magento_Catalog/js/list',
1110
relatedProducts: 'Magento_Catalog/js/related-products',
1211
upsellProducts: 'Magento_Catalog/js/upsell-products',

app/code/Magento/Catalog/view/frontend/web/js/compare.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,32 @@
22
* Copyright © 2016 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
define([
67
'uiComponent',
78
'Magento_Customer/js/customer-data',
8-
'mage/translate'
9-
], function (Component, customerData) {
9+
'jquery',
10+
'mage/mage',
11+
'mage/decorate'
12+
], function (Component, customerData, $) {
1013
'use strict';
1114

1215
var sidebarInitialized = false;
1316

17+
/**
18+
* Initialize sidebar
19+
*/
1420
function initSidebar() {
1521
if (sidebarInitialized) {
1622
return;
1723
}
18-
sidebarInitialized = true;
19-
require([
20-
'jquery',
21-
'mage/mage'
22-
], function ($) {
23-
/*eslint-disable max-len*/
24-
$('[data-role=compare-products-sidebar]').mage('compareItems', {
25-
'removeConfirmMessage': $.mage.__('Are you sure you want to remove this item from your Compare Products list?'),
26-
'removeSelector': '#compare-items a.action.delete',
27-
'clearAllConfirmMessage': $.mage.__('Are you sure you want to remove all items from your Compare Products list?'),
28-
'clearAllSelector': '#compare-clear-all'
29-
});
3024

31-
/*eslint-enable max-len*/
32-
});
25+
sidebarInitialized = true;
26+
$('[data-role=compare-products-sidebar]').decorate('list', true);
3327
}
3428

3529
return Component.extend({
30+
/** @inheritdoc */
3631
initialize: function () {
3732
this._super();
3833
this.compareProducts = customerData.get('compare-products');

app/code/Magento/Customer/view/frontend/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ var config = {
1010
address: 'Magento_Customer/address',
1111
changeEmailPassword: 'Magento_Customer/change-email-password',
1212
passwordStrengthIndicator: 'Magento_Customer/js/password-strength-indicator',
13-
zxcvbn: 'Magento_Customer/js/zxcvbn'
13+
zxcvbn: 'Magento_Customer/js/zxcvbn',
14+
addressValidation: 'Magento_Customer/js/addressValidation'
1415
}
1516
}
1617
};

0 commit comments

Comments
 (0)