Skip to content

Commit 3c48975

Browse files
authored
Merge pull request #1393 from PrestaShopCorp/fix/PAYSHIP-3576-v4-PS8
Release v8.4.4.1
2 parents eac35fe + c70df2a commit 3c48975

16 files changed

+403
-148
lines changed

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<module>
33
<name>ps_checkout</name>
44
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
5-
<version><![CDATA[8.4.4.0]]></version>
5+
<version><![CDATA[8.4.4.1]]></version>
66
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
77
<author><![CDATA[PrestaShop]]></author>
88
<tab><![CDATA[payments_gateways]]></tab>

config/admin/services.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ services:
1212
PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileReader:
1313
class: 'PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileReader'
1414
public: true
15+
arguments:
16+
- '@PrestaShop\Module\PrestashopCheckout\Logger\LoggerDirectory'
17+
- '@PrestaShop\Module\PrestashopCheckout\Logger\LoggerFileFinder'
18+
- '@PrestaShop\Module\PrestashopCheckout\Adapter\ValidateAdapter'

config/common.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,3 +500,7 @@ services:
500500
arguments:
501501
- '@PrestaShop\Module\PrestashopCheckout\System\SystemConfiguration'
502502
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalConfiguration'
503+
504+
PrestaShop\Module\PrestashopCheckout\Adapter\ValidateAdapter:
505+
class: 'PrestaShop\Module\PrestashopCheckout\Adapter\ValidateAdapter'
506+
public: true

controllers/admin/AdminAjaxPrestashopCheckoutController.php

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -708,53 +708,47 @@ public function ajaxProcessGetLogFiles()
708708
*/
709709
public function ajaxProcessGetLogs()
710710
{
711-
header('Content-type: application/json');
712-
713711
$filename = Tools::getValue('file');
714712
$offset = (int) Tools::getValue('offset');
715713
$limit = (int) Tools::getValue('limit');
716714

717-
if (empty($filename) || false === Validate::isFileName($filename)) {
718-
http_response_code(400);
719-
$this->ajaxDie(json_encode([
720-
'status' => false,
721-
'errors' => [
722-
'Filename is invalid.',
723-
],
724-
]));
725-
}
726-
727-
/** @var LoggerDirectory $loggerDirectory */
728-
$loggerDirectory = $this->module->getService(LoggerDirectory::class);
729715
/** @var LoggerFileReader $loggerFileReader */
730716
$loggerFileReader = $this->module->getService(LoggerFileReader::class);
731717
$fileData = [];
732718

733719
try {
734720
$fileData = $loggerFileReader->read(
735-
new SplFileObject($loggerDirectory->getPath() . $filename),
721+
$filename,
736722
$offset,
737723
$limit
738724
);
725+
} catch (InvalidArgumentException $exception) {
726+
$this->exitWithResponse([
727+
'status' => false,
728+
'httpCode' => 400,
729+
'errors' => [
730+
$exception->getMessage(),
731+
],
732+
]);
739733
} catch (Exception $exception) {
740-
http_response_code(500);
741-
$this->ajaxDie(json_encode([
734+
$this->exitWithResponse([
742735
'status' => false,
736+
'httpCode' => 500,
743737
'errors' => [
744738
$exception->getMessage(),
745739
],
746-
]));
740+
]);
747741
}
748742

749-
$this->ajaxDie(json_encode([
743+
$this->exitWithResponse([
750744
'status' => true,
751745
'file' => $fileData['filename'],
752746
'offset' => $fileData['offset'],
753747
'limit' => $fileData['limit'],
754748
'currentOffset' => $fileData['currentOffset'],
755749
'eof' => (int) $fileData['eof'],
756750
'lines' => $fileData['lines'],
757-
]));
751+
]);
758752
}
759753

760754
/**
@@ -1038,12 +1032,16 @@ public function ajaxProcessDownloadLogs()
10381032
{
10391033
$filename = Tools::getValue('file');
10401034

1041-
if (empty($filename) || false === Validate::isFileName($filename)) {
1035+
try {
1036+
/** @var LoggerFileReader $loggerFileReader */
1037+
$loggerFileReader = $this->module->getService(LoggerFileReader::class);
1038+
$loggerFileReader->validateFilename($filename);
1039+
} catch (InvalidArgumentException $exception) {
10421040
$this->exitWithResponse([
10431041
'status' => false,
10441042
'httpCode' => 400,
10451043
'errors' => [
1046-
'Filename is invalid.',
1044+
$exception->getMessage(),
10471045
],
10481046
]);
10491047
}

0 commit comments

Comments
 (0)