Skip to content

Commit bfd457c

Browse files
Merge pull request #7898 from magento-amigos/2.4-develop-prs
[Amigos] Community Contributions - 2.4-develop
2 parents 61241d8 + 0e63dc0 commit bfd457c

File tree

9 files changed

+128
-20
lines changed

9 files changed

+128
-20
lines changed

app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ private function convertElementsToSelect($elements, $attributesToConvert)
132132
$elements[$code]['dataType'] = 'select';
133133
$elements[$code]['formElement'] = 'select';
134134

135-
foreach ($options as $key => $value) {
135+
foreach ($options as $value) {
136136
$elements[$code]['options'][] = [
137-
'value' => $key,
137+
'value' => $value,
138138
'label' => $value,
139139
];
140140
}

app/code/Magento/Checkout/Controller/Cart/EstimatePost.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
namespace Magento\Checkout\Controller\Cart;
77

88
use Magento\Framework;
9+
use Magento\Framework\App\Action\HttpPostActionInterface;
910
use Magento\Checkout\Model\Cart as CustomerCart;
1011

11-
class EstimatePost extends \Magento\Checkout\Controller\Cart
12+
class EstimatePost extends \Magento\Checkout\Controller\Cart implements HttpPostActionInterface
1213
{
1314
/**
1415
* @var \Magento\Quote\Api\CartRepositoryInterface
@@ -63,9 +64,7 @@ public function execute()
6364
->setCity($city)
6465
->setPostcode($postcode)
6566
->setRegionId($regionId)
66-
->setRegion($region)
67-
->setCollectShippingRates(true);
68-
$this->quoteRepository->save($this->cart->getQuote());
67+
->setRegion($region);
6968
$this->cart->save();
7069
return $this->_goBack();
7170
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
10+
<policies>
11+
<policy id="script-src">
12+
<values>
13+
<value id="newrelic-agent" type="host">*.newrelic.com</value>
14+
<value id="newrelic-agent-data" type="host">*.nr-data.net</value>
15+
</values>
16+
</policy>
17+
<policy id="connect-src">
18+
<values>
19+
<value id="newrelic-agent" type="host">*.newrelic.com</value>
20+
<value id="newrelic-agent-data" type="host">*.nr-data.net</value>
21+
</values>
22+
</policy>
23+
</policies>
24+
</csp_whitelist>

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm
2121
{
2222
/**
23-
* Customer form factory
23+
* Customer Metadata form factory
2424
*
2525
* @var \Magento\Customer\Model\Metadata\FormFactory
2626
*/
2727
protected $_customerFormFactory;
2828

2929
/**
30-
* Json encoder
30+
* Framework Json encoder
3131
*
3232
* @var \Magento\Framework\Json\EncoderInterface
3333
*/
3434
protected $_jsonEncoder;
3535

3636
/**
37-
* Directory helper
37+
* Directory helper Data
3838
*
3939
* @var \Magento\Directory\Helper\Data
4040
*/
@@ -48,28 +48,28 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF
4848
protected $options;
4949

5050
/**
51-
* Address service
51+
* Address service - AddressRepositoryInterface
5252
*
5353
* @var \Magento\Customer\Api\AddressRepositoryInterface
5454
*/
5555
protected $addressService;
5656

5757
/**
58-
* Address helper
58+
* Customer Address helper
5959
*
6060
* @var \Magento\Customer\Helper\Address
6161
*/
6262
protected $_addressHelper;
6363

6464
/**
65-
* Search criteria builder
65+
* Search criteria builder for getList calls
6666
*
6767
* @var \Magento\Framework\Api\SearchCriteriaBuilder
6868
*/
6969
protected $searchCriteriaBuilder;
7070

7171
/**
72-
* Filter builder
72+
* Filter builder for getList calls
7373
*
7474
* @var \Magento\Framework\Api\FilterBuilder
7575
*/
@@ -235,9 +235,13 @@ protected function _prepareForm()
235235
if ($prefixElement) {
236236
$prefixOptions = $this->options->getNamePrefixOptions($this->getStore());
237237
if (!empty($prefixOptions)) {
238+
$mappedPrefixOptions = [];
239+
foreach ($prefixOptions as $prefix) {
240+
$mappedPrefixOptions[$prefix] = $prefix;
241+
}
238242
$fieldset->removeField($prefixElement->getId());
239243
$prefixField = $fieldset->addField($prefixElement->getId(), 'select', $prefixElement->getData(), '^');
240-
$prefixField->setValues($prefixOptions);
244+
$prefixField->setValues($mappedPrefixOptions);
241245
if ($this->getAddressId()) {
242246
$prefixField->addElementValues($this->getAddress()->getPrefix());
243247
}
@@ -322,6 +326,7 @@ private function processCountryOptions(\Magento\Framework\Data\Form\Element\Abst
322326
* Retrieve Directory Countries collection
323327
*
324328
* @deprecated 100.1.3
329+
* @see MAGETWO-711174: Introduce deprecated and since doc blocks.
325330
* @return \Magento\Directory\Model\ResourceModel\Country\Collection
326331
*/
327332
private function getCountriesCollection()
@@ -338,6 +343,7 @@ private function getCountriesCollection()
338343
* Retrieve Backend Quote Session
339344
*
340345
* @deprecated 100.1.3
346+
* @see MAGETWO-711174: Introduce deprecated and since doc blocks.
341347
* @return Quote
342348
*/
343349
private function getBackendQuoteSession()

app/code/Magento/User/Model/ResourceModel/User.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public function recordLogin(ModelUser $user)
123123
'logdate' => (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT),
124124
'lognum' => $user->getLognum() + 1,
125125
];
126+
127+
$user->setLogdate($data['logdate']);
128+
$user->setLognum($data['lognum']);
126129

127130
$condition = ['user_id = ?' => (int)$user->getUserId()];
128131

dev/tests/integration/testsuite/Magento/Framework/Url/Helper/DataTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ protected function setUp(): void
2121

2222
public function testGetCurrentBase64Url()
2323
{
24-
$this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MS8,', $this->_helper->getCurrentBase64Url());
24+
$this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MS8~', $this->_helper->getCurrentBase64Url());
2525
}
2626

2727
public function testGetEncodedUrl()
2828
{
29-
$this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MS8,', $this->_helper->getEncodedUrl());
30-
$this->assertEquals('aHR0cDovL2V4YW1wbGUuY29tLw,,', $this->_helper->getEncodedUrl('http://example.com/'));
29+
$this->assertEquals('aHR0cDovL2xvY2FsaG9zdDo4MS8~', $this->_helper->getEncodedUrl());
30+
$this->assertEquals('aHR0cDovL2V4YW1wbGUuY29tLw~~', $this->_helper->getEncodedUrl('http://example.com/'));
3131
}
3232
}

dev/tests/integration/testsuite/Magento/Shipping/Helper/DataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function getTrackingPopupUrlBySalesModelDataProvider()
145145
'setId',
146146
42,
147147
'abc',
148-
'http://localhost/index.php/shipping/tracking/popup?hash=c2hpcF9pZDo0MjphYmM%2C'
148+
'http://localhost/index.php/shipping/tracking/popup?hash=c2hpcF9pZDo0MjphYmM%7E'
149149
],
150150
[\Magento\Sales\Model\Order\Shipment\Track::class,
151151
'setEntityId',

lib/internal/Magento/Framework/Url/Encoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
class Encoder implements EncoderInterface
99
{
1010
/**
11-
* base64_encode() for URLs encoding
11+
* Method base64_encode() for URLs encoding
1212
*
1313
* @param string $url
1414
* @return string
1515
*/
1616
public function encode($url)
1717
{
18-
return strtr(base64_encode($url), '+/=', '-_,');
18+
return strtr(base64_encode($url), '+/=', '-_~');
1919
}
2020
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Url\Test\Unit;
9+
10+
use Magento\Framework\Url\Encoder;
11+
use PHPUnit\Framework\TestCase;
12+
13+
class EncoderTest extends TestCase
14+
{
15+
/**
16+
* @var Encoder|null
17+
*/
18+
private ?Encoder $encoder = null;
19+
20+
protected function setUp(): void
21+
{
22+
parent::setUp();
23+
24+
$this->encoder = new Encoder();
25+
}
26+
27+
public function testEncode(): void
28+
{
29+
$url = 'http://magento2.adobe/encoding';
30+
31+
self::assertEquals('aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5n', $this->encoder->encode($url));
32+
}
33+
34+
/**
35+
* Equals should be replaced by a non-reserved character.
36+
*/
37+
public function testEncodeWithEndingSlash(): void
38+
{
39+
$url = 'http://magento2.adobe/encoding/with/longer/url/';
40+
41+
self::assertEquals(
42+
'aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8~',
43+
$this->encoder->encode($url)
44+
);
45+
}
46+
47+
/**
48+
* @dataProvider rfc3986Urls
49+
*
50+
* @see https://www.rfc-editor.org/rfc/rfc3986.html#section-2.2
51+
*/
52+
public function testEncodeNotContainingRfc3986ReservedCharacters(string $url): void
53+
{
54+
$genDelims = [':', '/', '?', '#', '[', ']', '@'];
55+
$subDelims = ['!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '='];
56+
57+
$encodedUrl = $this->encoder->encode($url);
58+
59+
array_map(static function (string $value) use ($encodedUrl): void {
60+
self::assertStringNotContainsString($value, $encodedUrl);
61+
}, $genDelims);
62+
63+
array_map(static function (string $value) use ($encodedUrl): void {
64+
self::assertStringNotContainsString($value, $encodedUrl);
65+
}, $subDelims);
66+
}
67+
68+
public function rfc3986Urls(): array
69+
{
70+
return [
71+
['http://magento2.adobe/encoding/with/longer/url/'],
72+
['http://magento2.adobe/some/other/random/url?currency=eur&price=2'],
73+
['http://magento2.adobe/yet/not/done/url#anchor']
74+
];
75+
}
76+
}

0 commit comments

Comments
 (0)