Skip to content

Commit b0a9ae0

Browse files
committed
Merge remote-tracking branch 'origin/2.1.16-develop' into 2.1.16-develop-pr57
2 parents db53f1c + 4064ada commit b0a9ae0

File tree

18 files changed

+219
-50
lines changed

18 files changed

+219
-50
lines changed

.htaccess

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ DirectoryIndex index.php
114114
order allow,deny
115115
deny from all
116116
</Files>
117+
<Files .user.ini>
118+
<IfVersion < 2.4>
119+
order allow,deny
120+
deny from all
121+
</IfVersion>
122+
<IfVersion >= 2.4>
123+
Require all denied
124+
</IfVersion>
125+
</Files>
117126
ErrorDocument 404 /pub/errors/404.php
118127
ErrorDocument 403 /pub/errors/404.php
119128
<IfModule mod_headers.c>

.htaccess.sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ DirectoryIndex index.php
278278
order allow,deny
279279
deny from all
280280
</Files>
281+
<Files .user.ini>
282+
<IfVersion < 2.4>
283+
order allow,deny
284+
deny from all
285+
</IfVersion>
286+
<IfVersion >= 2.4>
287+
Require all denied
288+
</IfVersion>
289+
</Files>
281290

282291
# For 404s and 403s that aren't handled by the application, show plain 404 response
283292
ErrorDocument 404 /pub/errors/404.php

app/code/Magento/Email/view/frontend/email/header.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343

4444
{{if logo_height}}
4545
height="{{var logo_height}}"
46-
{{else}}
47-
height="52"
4846
{{/if}}
4947

5048
src="{{var logo_url}}"
Loading

app/code/Magento/PageCache/Model/System/Config/Backend/Ttl.php

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,49 @@
66

77
namespace Magento\PageCache\Model\System\Config\Backend;
88

9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\Escaper;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\Exception\LocalizedException;
13+
914
/**
10-
* Backend model for processing Public content cache lifetime settings
15+
* Backend model for processing Public content cache lifetime settings.
1116
*
1217
* Class Ttl
1318
*/
1419
class Ttl extends \Magento\Framework\App\Config\Value
1520
{
1621
/**
17-
* Throw exception if Ttl data is invalid or empty
22+
* @var Escaper
23+
*/
24+
private $escaper;
25+
26+
/**
27+
* @param \Magento\Framework\Model\Context $context
28+
* @param \Magento\Framework\Registry $registry
29+
* @param ScopeConfigInterface $config
30+
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
31+
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
32+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
33+
* @param array $data
34+
* @param Escaper|null $escaper
35+
*/
36+
public function __construct(
37+
\Magento\Framework\Model\Context $context,
38+
\Magento\Framework\Registry $registry,
39+
ScopeConfigInterface $config,
40+
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
41+
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
42+
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
43+
array $data = [],
44+
Escaper $escaper = null
45+
) {
46+
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
47+
$this->escaper = $escaper ?: ObjectManager::getInstance()->create(Escaper::class);
48+
}
49+
50+
/**
51+
* Throw exception if Ttl data is invalid or empty.
1852
*
1953
* @return $this
2054
* @throws \Magento\Framework\Exception\LocalizedException
@@ -23,10 +57,14 @@ public function beforeSave()
2357
{
2458
$value = $this->getValue();
2559
if ($value < 0 || !preg_match('/^[0-9]+$/', $value)) {
26-
throw new \Magento\Framework\Exception\LocalizedException(
27-
__('Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.', $value)
60+
throw new LocalizedException(
61+
__(
62+
'Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.',
63+
$this->escaper->escapeHtml($value)
64+
)
2865
);
2966
}
67+
3068
return $this;
3169
}
3270
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageCache\Test\Unit\Model\System\Config\Backend;
8+
9+
use Magento\PageCache\Model\System\Config\Backend\Ttl;
10+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\Escaper;
13+
use Magento\Framework\Exception\LocalizedException;
14+
15+
class TtlTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/**
18+
* @var Ttl
19+
*/
20+
private $ttl;
21+
22+
/*
23+
* @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $escaperMock;
26+
27+
/**
28+
* @inheritDoc
29+
*/
30+
protected function setUp()
31+
{
32+
$objectManager = new ObjectManager($this);
33+
$configMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
34+
$configMock->expects($this->any())
35+
->method('getValue')
36+
->with('system/full_page_cache/default')
37+
->willReturn(['ttl' => 86400]);
38+
39+
$this->escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
40+
41+
$this->ttl = $objectManager->getObject(
42+
Ttl::class,
43+
[
44+
'config' => $configMock,
45+
'data' => ['field' => 'ttl'],
46+
'escaper' => $this->escaperMock,
47+
]
48+
);
49+
}
50+
51+
/**
52+
* @return array
53+
*/
54+
public function getValidValues()
55+
{
56+
return [
57+
['3600', '3600'],
58+
['10000', '10000'],
59+
['100000', '100000'],
60+
['1000000', '1000000'],
61+
];
62+
}
63+
64+
/**
65+
* @param string $value
66+
* @param string $expectedValue
67+
* @return void
68+
* @dataProvider getValidValues
69+
*/
70+
public function testBeforeSave($value, $expectedValue)
71+
{
72+
$this->ttl->setValue($value);
73+
$this->ttl->beforeSave();
74+
$this->assertEquals($expectedValue, $this->ttl->getValue());
75+
}
76+
77+
/**
78+
* @return array
79+
*/
80+
public function getInvalidValues()
81+
{
82+
return [
83+
['<script>alert(1)</script>'],
84+
['apple'],
85+
['123 street'],
86+
['-123'],
87+
];
88+
}
89+
90+
/**
91+
* @param string $value
92+
* @return void
93+
* @dataProvider getInvalidValues
94+
*/
95+
public function testBeforeSaveInvalid($value)
96+
{
97+
$this->ttl->setValue($value);
98+
$this->escaperMock->expects($this->any())->method('escapeHtml')->with($value)->willReturn($value);
99+
$expMessage = sprintf(
100+
'Ttl value "%s" is not valid. Please use only numbers equal or greater than zero.',
101+
$value
102+
);
103+
$this->setExpectedException(LocalizedException::class, $expMessage);
104+
$this->ttl->beforeSave();
105+
}
106+
}

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ protected function _getXmlQuotes()
623623
$serviceCode = null;
624624
} else {
625625
$params['10_action'] = 'Rate';
626-
$serviceCode = $rowRequest->getProduct() ? $rowRequest->getProduct() : '';
626+
$serviceCode = $rowRequest->getProduct() ? $rowRequest->getProduct() : null;
627627
}
628628
$serviceDescription = $serviceCode ? $this->getShipmentByCode($serviceCode) : '';
629629

@@ -657,8 +657,8 @@ protected function _getXmlQuotes()
657657
<Shipper>
658658
XMLRequest;
659659

660-
if ($this->getConfigFlag('negotiated_active') && ($shipper = $this->getConfigData('shipper_number'))) {
661-
$xmlParams .= "<ShipperNumber>{$shipper}</ShipperNumber>";
660+
if ($this->getConfigFlag('negotiated_active') && ($shipperNumber = $this->getConfigData('shipper_number'))) {
661+
$xmlParams .= "<ShipperNumber>{$shipperNumber}</ShipperNumber>";
662662
}
663663

664664
if ($rowRequest->getIsReturn()) {
@@ -681,6 +681,7 @@ protected function _getXmlQuotes()
681681
<StateProvinceCode>{$shipperStateProvince}</StateProvinceCode>
682682
</Address>
683683
</Shipper>
684+
684685
<ShipTo>
685686
<Address>
686687
<PostalCode>{$params['19_destPostal']}</PostalCode>
@@ -696,8 +697,7 @@ protected function _getXmlQuotes()
696697
$xmlParams .= <<<XMLRequest
697698
</Address>
698699
</ShipTo>
699-
700-
700+
701701
<ShipFrom>
702702
<Address>
703703
<PostalCode>{$params['15_origPostal']}</PostalCode>
@@ -707,9 +707,13 @@ protected function _getXmlQuotes()
707707
</ShipFrom>
708708
709709
<Package>
710-
<PackagingType><Code>{$params['48_container']}</Code></PackagingType>
710+
<PackagingType>
711+
<Code>{$params['48_container']}</Code>
712+
</PackagingType>
711713
<PackageWeight>
712-
<UnitOfMeasurement><Code>{$rowRequest->getUnitMeasure()}</Code></UnitOfMeasurement>
714+
<UnitOfMeasurement>
715+
<Code>{$rowRequest->getUnitMeasure()}</Code>
716+
</UnitOfMeasurement>
713717
<Weight>{$params['23_weight']}</Weight>
714718
</PackageWeight>
715719
</Package>
@@ -720,8 +724,8 @@ protected function _getXmlQuotes()
720724
}
721725

722726
$xmlParams .= <<<XMLRequest
723-
</Shipment>
724-
</RatingServiceSelectionRequest>
727+
</Shipment>
728+
</RatingServiceSelectionRequest>
725729
XMLRequest;
726730

727731
$xmlRequest .= $xmlParams;
@@ -873,10 +877,13 @@ protected function _parseXmlResponse($xmlResponse)
873877
$error = $this->_rateErrorFactory->create();
874878
$error->setCarrier('ups');
875879
$error->setCarrierTitle($this->getConfigData('title'));
880+
if ($this->getConfigData('specificerrmsg') !== '') {
881+
$errorTitle = $this->getConfigData('specificerrmsg');
882+
}
876883
if (!isset($errorTitle)) {
877884
$errorTitle = __('Cannot retrieve shipping rates');
878885
}
879-
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
886+
$error->setErrorMessage($errorTitle);
880887
$result->append($error);
881888
} else {
882889
foreach ($priceArr as $method => $price) {
@@ -982,14 +989,14 @@ protected function _getXmlTracking($trackings)
982989
$xmlRequest = $this->_xmlAccessRequest;
983990

984991
/**
985-
* RequestOption==>'activity' or '1' to request all activities
992+
* RequestOption==>'1' to request all activities
986993
*/
987994
$xmlRequest .= <<<XMLAuth
988995
<?xml version="1.0" ?>
989996
<TrackRequest xml:lang="en-US">
990997
<Request>
991998
<RequestAction>Track</RequestAction>
992-
<RequestOption>activity</RequestOption>
999+
<RequestOption>1</RequestOption>
9931000
</Request>
9941001
<TrackingNumber>$tracking</TrackingNumber>
9951002
<IncludeFreight>01</IncludeFreight>
@@ -1064,15 +1071,15 @@ protected function _parseXmlTrackingResponse($trackingValue, $xmlResponse)
10641071
if ($activityTags) {
10651072
$index = 1;
10661073
foreach ($activityTags as $activityTag) {
1067-
$addArr = [];
1074+
$addressArr = [];
10681075
if (isset($activityTag->ActivityLocation->Address->City)) {
1069-
$addArr[] = (string)$activityTag->ActivityLocation->Address->City;
1076+
$addressArr[] = (string)$activityTag->ActivityLocation->Address->City;
10701077
}
10711078
if (isset($activityTag->ActivityLocation->Address->StateProvinceCode)) {
1072-
$addArr[] = (string)$activityTag->ActivityLocation->Address->StateProvinceCode;
1079+
$addressArr[] = (string)$activityTag->ActivityLocation->Address->StateProvinceCode;
10731080
}
10741081
if (isset($activityTag->ActivityLocation->Address->CountryCode)) {
1075-
$addArr[] = (string)$activityTag->ActivityLocation->Address->CountryCode;
1082+
$addressArr[] = (string)$activityTag->ActivityLocation->Address->CountryCode;
10761083
}
10771084
$dateArr = [];
10781085
$date = (string)$activityTag->Date;
@@ -1096,8 +1103,8 @@ protected function _parseXmlTrackingResponse($trackingValue, $xmlResponse)
10961103
//HH:MM:SS
10971104
$resultArr['deliverylocation'] = (string)$activityTag->ActivityLocation->Description;
10981105
$resultArr['signedby'] = (string)$activityTag->ActivityLocation->SignedForByName;
1099-
if ($addArr) {
1100-
$resultArr['deliveryto'] = implode(', ', $addArr);
1106+
if ($addressArr) {
1107+
$resultArr['deliveryto'] = implode(', ', $addressArr);
11011108
}
11021109
} else {
11031110
$tempArr = [];
@@ -1106,8 +1113,8 @@ protected function _parseXmlTrackingResponse($trackingValue, $xmlResponse)
11061113
//YYYY-MM-DD
11071114
$tempArr['deliverytime'] = implode(':', $timeArr);
11081115
//HH:MM:SS
1109-
if ($addArr) {
1110-
$tempArr['deliverylocation'] = implode(', ', $addArr);
1116+
if ($addressArr) {
1117+
$tempArr['deliverylocation'] = implode(', ', $addressArr);
11111118
}
11121119
$packageProgress[] = $tempArr;
11131120
}

app/code/Magento/Ups/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<model>Magento\Ups\Model\Carrier</model>
2626
<pickup>CC</pickup>
2727
<title>United Parcel Service</title>
28-
<tracking_xml_url>https://www.ups.com/ups.app/xml/Track</tracking_xml_url>
28+
<tracking_xml_url>https://onlinetools.ups.com/ups.app/xml/Track</tracking_xml_url>
2929
<unit_of_measure>LBS</unit_of_measure>
3030
<username backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
3131
<password backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
Loading

0 commit comments

Comments
 (0)