Skip to content

Commit fd6ab07

Browse files
author
Dale Sikkema
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-45226-unserialize-rce
2 parents d1f0919 + f85e691 commit fd6ab07

File tree

14 files changed

+500
-124
lines changed

14 files changed

+500
-124
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 172 additions & 75 deletions
Large diffs are not rendered by default.

app/code/Magento/Braintree/view/frontend/web/template/payment/cc-form.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<form class="form" id="co-transparent-form" action="#" method="post" data-bind="mageInit: {
3232
'transparent':{
3333
'context': context(),
34+
'gateway': getCode(),
3435
'controller': getControllerName(),
3536
'orderSaveUrl':getPlaceOrderUrl(),
3637
}, 'validation':[]}">
@@ -111,8 +112,15 @@
111112
</label>
112113
<div class="control">
113114
<input type="number" name="payment[cc_number]" class="input-text" value=""
114-
data-bind="attr: {id: getCode() + '_cc_number', title: $t('Credit Card Number'), 'data-container': getCode() + '-cc-number', 'data-validate': JSON.stringify({'required-number':true, 'validate-cc-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})},
115-
enable: true, value: creditCardNumber"/>
115+
data-bind="attr: {
116+
autocomplete: off,
117+
id: getCode() + '_cc_number',
118+
title: $t('Credit Card Number'),
119+
'data-container': getCode() + '-cc-number',
120+
'data-validate': JSON.stringify({'required-number':true, 'validate-card-type':getCcAvailableTypesValues(), 'validate-card-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})},
121+
enable: isActive($parents),
122+
value: creditCardNumber,
123+
valueUpdate: 'keyup' "/>
116124
</div>
117125
</div>
118126
<div class="field date required" data-bind="attr: {id: getCode() + '_cc_type_exp_div'}, visible: isCcFormShown">

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ define([
1010
'Magento_Customer/js/customer-data',
1111
'Magento_Ui/js/modal/alert',
1212
'Magento_Ui/js/modal/confirm',
13-
'Magento_Customer/js/customer-data',
1413
"jquery/ui",
1514
"mage/decorate"
16-
], function($, authenticationPopup, customerData, alert, confirm, customerData){
15+
], function($, authenticationPopup, customerData, alert, confirm){
1716

1817
$.widget('mage.sidebar', {
1918
options: {
@@ -27,14 +26,16 @@ define([
2726
* @private
2827
*/
2928
_create: function () {
30-
var self = this;
31-
3229
this._initContent();
33-
customerData.get('cart').subscribe(function () {
34-
$(self.options.targetElement).trigger('contentUpdated');
35-
self._calcHeight();
36-
self._isOverflowed();
37-
});
30+
},
31+
32+
/**
33+
* Update sidebar block.
34+
*/
35+
update: function () {
36+
$(this.options.targetElement).trigger('contentUpdated');
37+
this._calcHeight();
38+
this._isOverflowed();
3839
},
3940

4041
_initContent: function() {
@@ -219,6 +220,7 @@ define([
219220
console.log(JSON.stringify(error));
220221
});
221222
},
223+
222224
/**
223225
* Calculate height of minicart list
224226
*
@@ -228,22 +230,18 @@ define([
228230
var self = this,
229231
height = 0,
230232
counter = this.options.maxItemsVisible,
231-
target = $(this.options.minicart.list)
232-
.clone()
233-
.attr('style', 'position: absolute !important; top: -10000 !important;')
234-
.appendTo('body');
233+
target = $(this.options.minicart.list);
234+
235+
target.children().each(function () {
236+
var outerHeight = $(this).outerHeight();
235237

236-
this.scrollHeight = 0;
237-
target.children().each(function() {
238238
if (counter-- > 0) {
239-
height += $(this).height();
239+
height += outerHeight;
240240
}
241-
self.scrollHeight += $(this).height();
241+
self.scrollHeight += outerHeight;
242242
});
243243

244-
target.remove();
245-
246-
$(this.options.minicart.list).css('height', height);
244+
target.height(height);
247245
}
248246
});
249247

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ define([
2020
});
2121

2222
function initSidebar() {
23+
if (minicart.data('mageSidebar')) {
24+
minicart.sidebar('update');
25+
}
26+
2327
if (!$('[data-role=product-item]').length) {
2428
return false;
2529
}

app/code/Magento/Checkout/view/frontend/web/template/minicart/content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<div data-action="scroll" class="minicart-items-wrapper">
6868
<ol id="mini-cart" class="minicart-items" data-bind="foreach: { data: cart().items, as: 'item' }">
6969
<!-- ko foreach: $parent.getRegion($parent.getItemRenderer(item.product_type)) -->
70-
<!-- ko template: {name: getTemplate(), data: item, afterRender: $parents[1].initSidebar()} --><!-- /ko -->
70+
<!-- ko template: {name: getTemplate(), data: item, afterRender: function() {$parents[1].initSidebar()}} --><!-- /ko -->
7171
<!-- /ko -->
7272
</ol>
7373
</div>

app/code/Magento/Customer/Model/Checkout/ConfigProvider.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Customer\Model\Url;
1010
use Magento\Framework\UrlInterface;
1111
use Magento\Store\Model\StoreManagerInterface;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Customer\Model\Form;
14+
use Magento\Store\Model\ScopeInterface;
1215

1316
class ConfigProvider implements ConfigProviderInterface
1417
{
@@ -22,16 +25,24 @@ class ConfigProvider implements ConfigProviderInterface
2225
*/
2326
protected $urlBuilder;
2427

28+
/**
29+
* @var ScopeConfigInterface
30+
*/
31+
protected $scopeConfig;
32+
2533
/**
2634
* @param UrlInterface $urlBuilder
2735
* @param StoreManagerInterface $storeManager
36+
* @param ScopeConfigInterface $scopeConfig
2837
*/
2938
public function __construct(
3039
UrlInterface $urlBuilder,
31-
StoreManagerInterface $storeManager
40+
StoreManagerInterface $storeManager,
41+
ScopeConfigInterface $scopeConfig
3242
) {
3343
$this->urlBuilder = $urlBuilder;
3444
$this->storeManager = $storeManager;
45+
$this->scopeConfig = $scopeConfig;
3546
}
3647

3748
/**
@@ -42,9 +53,24 @@ public function getConfig()
4253
return [
4354
'customerLoginUrl' => $this->getLoginUrl(),
4455
'isRedirectRequired' => $this->isRedirectRequired(),
56+
'autocomplete' => $this->isAutocompleteEnabled(),
4557
];
4658
}
4759

60+
/**
61+
* Is autocomplete enabled for storefront
62+
*
63+
* @return string
64+
* @codeCoverageIgnore
65+
*/
66+
protected function isAutocompleteEnabled()
67+
{
68+
return $this->scopeConfig->getValue(
69+
Form::XML_PATH_ENABLE_AUTOCOMPLETE,
70+
ScopeInterface::SCOPE_STORE
71+
) ? 'on' : 'off';
72+
}
73+
4874
/**
4975
* Returns URL to login controller action
5076
*
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Test\Unit\Model\Checkout;
7+
8+
use Magento\Customer\Model\Checkout\ConfigProvider;
9+
use Magento\Framework\UrlInterface;
10+
use Magento\Store\Model\StoreManagerInterface;
11+
use Magento\Store\Api\Data\StoreInterface;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Customer\Model\Url;
14+
use Magento\Customer\Model\Form;
15+
use Magento\Store\Model\ScopeInterface;
16+
17+
class ConfigProviderTest extends \PHPUnit_Framework_TestCase
18+
{
19+
/**
20+
* @var ConfigProvider
21+
*/
22+
protected $provider;
23+
24+
/**
25+
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
protected $storeManager;
28+
29+
/**
30+
* @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
protected $urlBuilder;
33+
34+
/**
35+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
protected $scopeConfig;
38+
39+
/**
40+
* @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
protected $store;
43+
44+
public function setUp()
45+
{
46+
$this->storeManager = $this->getMockForAbstractClass(
47+
'Magento\Store\Model\StoreManagerInterface',
48+
[],
49+
'',
50+
false
51+
);
52+
$this->urlBuilder = $this->getMockForAbstractClass(
53+
'Magento\Framework\UrlInterface',
54+
[],
55+
'',
56+
false
57+
);
58+
$this->scopeConfig = $this->getMockForAbstractClass(
59+
'Magento\Framework\App\Config\ScopeConfigInterface',
60+
[],
61+
'',
62+
false
63+
);
64+
$this->store = $this->getMockForAbstractClass(
65+
'Magento\Store\Api\Data\StoreInterface',
66+
[],
67+
'',
68+
false,
69+
false,
70+
true,
71+
['getBaseUrl']
72+
);
73+
74+
$this->provider = new ConfigProvider(
75+
$this->urlBuilder,
76+
$this->storeManager,
77+
$this->scopeConfig
78+
);
79+
}
80+
81+
public function testGetConfigWithoutRedirect()
82+
{
83+
$loginUrl = 'http://url.test/customer/login';
84+
$baseUrl = 'http://base-url.test';
85+
86+
$this->urlBuilder->expects($this->exactly(2))
87+
->method('getUrl')
88+
->with(Url::ROUTE_ACCOUNT_LOGIN)
89+
->willReturn($loginUrl);
90+
$this->storeManager->expects($this->once())
91+
->method('getStore')
92+
->willReturn($this->store);
93+
$this->store->expects($this->once())
94+
->method('getBaseUrl')
95+
->willReturn($baseUrl);
96+
$this->scopeConfig->expects($this->once())
97+
->method('getValue')
98+
->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE)
99+
->willReturn(1);
100+
$this->assertEquals(
101+
[
102+
'customerLoginUrl' => $loginUrl,
103+
'isRedirectRequired' => true,
104+
'autocomplete' => 'on',
105+
],
106+
$this->provider->getConfig()
107+
);
108+
}
109+
110+
public function testGetConfig()
111+
{
112+
$loginUrl = 'http://base-url.test/customer/login';
113+
$baseUrl = 'http://base-url.test';
114+
115+
$this->urlBuilder->expects($this->exactly(2))
116+
->method('getUrl')
117+
->with(Url::ROUTE_ACCOUNT_LOGIN)
118+
->willReturn($loginUrl);
119+
$this->storeManager->expects($this->once())
120+
->method('getStore')
121+
->willReturn($this->store);
122+
$this->store->expects($this->once())
123+
->method('getBaseUrl')
124+
->willReturn($baseUrl);
125+
$this->scopeConfig->expects($this->once())
126+
->method('getValue')
127+
->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE)
128+
->willReturn(0);
129+
$this->assertEquals(
130+
[
131+
'customerLoginUrl' => $loginUrl,
132+
'isRedirectRequired' => false,
133+
'autocomplete' => 'off',
134+
],
135+
$this->provider->getConfig()
136+
);
137+
}
138+
}

app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ define(
2222
return Component.extend({
2323
registerUrl: window.authenticationPopup.customerRegisterUrl,
2424
forgotPasswordUrl: window.authenticationPopup.customerForgotPasswordUrl,
25+
autocomplete: window.checkout.autocomplete,
2526
modalWindow: null,
2627
isLoading: ko.observable(false),
2728

app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
id="email"
6161
type="email"
6262
class="input-text"
63+
data-bind="attr: {autocomplete: autocomplete}"
6364
data-validate="{required:true, 'validate-email':true}">
6465
</div>
6566
</div>
@@ -70,6 +71,7 @@
7071
type="password"
7172
class="input-text"
7273
id="pass"
74+
data-bind="attr: {autocomplete: autocomplete}"
7375
data-validate="{required:true, 'validate-password':true}">
7476
</div>
7577
</div>

app/code/Magento/Paypal/Model/Hostedpro/Request.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,11 @@ protected function _getAmountData(Order $order)
174174
private function getNonTaxableAmount(Order $order)
175175
{
176176
return [
177-
'subtotal' => $this->_formatPrice(
178-
$this->_formatPrice(
179-
$order->getPayment()->getBaseAmountAuthorized()
180-
) - $this->_formatPrice(
181-
$order->getBaseTaxAmount()
182-
) - $this->_formatPrice(
183-
$order->getBaseShippingAmount()
184-
)
185-
),
177+
'subtotal' => $this->_formatPrice($order->getBaseSubtotal()),
178+
'total' => $this->_formatPrice($order->getPayment()->getBaseAmountAuthorized()),
186179
'tax' => $this->_formatPrice($order->getBaseTaxAmount()),
187180
'shipping' => $this->_formatPrice($order->getBaseShippingAmount()),
181+
'discount' => $this->_formatPrice(abs($order->getBaseDiscountAmount()))
188182
];
189183
}
190184

0 commit comments

Comments
 (0)