From 8cdf04390e43184aef85a26855c40a9c0a33309e Mon Sep 17 00:00:00 2001 From: Pieter Cappelle Date: Sun, 24 Dec 2017 13:30:07 +0100 Subject: [PATCH 1/3] Fix import from external jpeg images --- .../Model/Import/Uploader.php | 9 +++++++ .../Test/Unit/Model/Import/UploaderTest.php | 24 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php index 6ae553b028a98..7d63448487e6b 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php @@ -161,6 +161,15 @@ public function move($fileName, $renameFileOff = false) $read = $this->_readFactory->create($url, DriverPool::HTTPS); } + //only use filename (for URI with query parameters) + $parsedUrl = parse_url($url); + if ($parsedUrl['path']) { + $urlPathValues = explode('/', $parsedUrl['path']); + if (!empty($urlPathValues)) { + $fileName = end($urlPathValues); + } + } + $fileName = preg_replace('/[^a-z0-9\._-]+/i', '', $fileName); $this->_directory->writeFile( $this->_directory->getRelativePath($this->getTmpDir() . '/' . $fileName), diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php index e28c2e1f3c01d..f6a211bc47c62 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php @@ -217,12 +217,32 @@ public function moveFileUrlDataProvider() [ '$fileUrl' => 'http://test_uploader_file', '$expectedHost' => 'test_uploader_file', - '$expectedFileName' => 'httptest_uploader_file', + '$expectedFileName' => 'test_uploader_file', ], [ '$fileUrl' => 'https://!:^&`;file', '$expectedHost' => '!:^&`;file', - '$expectedFileName' => 'httpsfile', + '$expectedFileName' => 'file', + ], + [ + '$fileUrl' => 'https://www.google.com/image.jpg', + '$expectedHost' => 'www.google.com/image.jpg', + '$expectedFileName' => 'image.jpg', + ], + [ + '$fileUrl' => 'https://www.google.com/image.jpg?param=1', + '$expectedHost' => 'www.google.com/image.jpg?param=1', + '$expectedFileName' => 'image.jpg', + ], + [ + '$fileUrl' => 'https://www.google.com/image.jpg?param=1¶m=2', + '$expectedHost' => 'www.google.com/image.jpg?param=1¶m=2', + '$expectedFileName' => 'image.jpg', + ], + [ + '$fileUrl' => 'http://www.google.com/image.jpg?param=1¶m=2', + '$expectedHost' => 'www.google.com/image.jpg?param=1¶m=2', + '$expectedFileName' => 'image.jpg', ], ]; } From 53292d37074044e644eacdef9adfa79df5199662 Mon Sep 17 00:00:00 2001 From: Pieter Cappelle Date: Sat, 30 Dec 2017 12:41:58 +0100 Subject: [PATCH 2/3] Use of parse_url PHP_URL_PATH variable. --- .../Magento/CatalogImportExport/Model/Import/Uploader.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php index 7d63448487e6b..ac94493722fb1 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php @@ -162,9 +162,9 @@ public function move($fileName, $renameFileOff = false) } //only use filename (for URI with query parameters) - $parsedUrl = parse_url($url); - if ($parsedUrl['path']) { - $urlPathValues = explode('/', $parsedUrl['path']); + $parsedUrlPath = parse_url($url, PHP_URL_PATH); + if ($parsedUrlPath) { + $urlPathValues = explode('/', $parsedUrlPath); if (!empty($urlPathValues)) { $fileName = end($urlPathValues); } From 9749465d20943a9c2637d0132fd710c3c59abb00 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Thu, 19 Oct 2017 22:20:59 +0200 Subject: [PATCH 3/3] Changed typo where a string to be translated used double space "configure your" --- app/code/Magento/Paypal/i18n/en_US.csv | 2 +- .../templates/system/config/payflowlink/advanced.phtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Paypal/i18n/en_US.csv b/app/code/Magento/Paypal/i18n/en_US.csv index 164feea71511f..797edbf8bfa1e 100644 --- a/app/code/Magento/Paypal/i18n/en_US.csv +++ b/app/code/Magento/Paypal/i18n/en_US.csv @@ -367,7 +367,7 @@ expires,expires here,here " to learn more."," to learn more." "Important: ","Important: " -"To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website.","To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website." +"To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website.","To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website." "Once you log into your PayPal Advanced account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below","Once you log into your PayPal Advanced account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below" "To use PayPal Payflow Link, you must configure your PayPal Payflow Link account on the PayPal website.","To use PayPal Payflow Link, you must configure your PayPal Payflow Link account on the PayPal website." "Once you log into your PayPal Payflow Link account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below","Once you log into your PayPal Payflow Link account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below" diff --git a/app/code/Magento/Paypal/view/adminhtml/templates/system/config/payflowlink/advanced.phtml b/app/code/Magento/Paypal/view/adminhtml/templates/system/config/payflowlink/advanced.phtml index 2339b9ca38534..127d5bd14db42 100644 --- a/app/code/Magento/Paypal/view/adminhtml/templates/system/config/payflowlink/advanced.phtml +++ b/app/code/Magento/Paypal/view/adminhtml/templates/system/config/payflowlink/advanced.phtml @@ -12,7 +12,7 @@

escapeHtml(__('Important: ')) ?> - escapeHtml(__('To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website.')) ?> + escapeHtml(__('To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website.')) ?> escapeHtml(__('Once you log into your PayPal Advanced account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below')) ?>