Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Length header match is case sensitive #1

Open
andrewladlow opened this issue Dec 4, 2020 · 0 comments
Open

Content-Length header match is case sensitive #1

andrewladlow opened this issue Dec 4, 2020 · 0 comments

Comments

@andrewladlow
Copy link

andrewladlow commented Dec 4, 2020

The value of the Content-Length: header is checked in a preg_match in https://github.com/sonassi/magento-download-archive/blob/master/src/Download.php#L158 to verify a given file's size, but the header returned from curl is content-length: instead, so the value of $contentLength is undefined.

If we add an echo $data; below https://github.com/sonassi/magento-download-archive/blob/master/src/Download.php#L155 to test, the output when running the phar with these options:

[0]: Other
[0]: magento-sample-data-1.9.1.0.zip

is:

Downloading magento-sample-data-1.9.1.0.zip
--
HTTP/2 200
date: Fri, 04 Dec 2020 15:48:01 GMT
content-type: application/zip
content-length: 440832557
server: nginx
last-modified: Wed, 18 Dec 2019 16:58:04 GMT
set-cookie: PHPSESSID=e6446bca395b5ae940ca4e71c1aff82a; expires=Fri, 04-Dec-2020 16:03:01 GMT; Max-Age=900; path=/; domain=www.magentocommerce.com; secure; HttpOnly
cache-control: must-revalidate, post-check=0, pre-check=0
expires: Thu, 01 Jan 1970 00:00:00 GMT
content-disposition: attachment; filename=magento-sample-data-1.9.1.0-2015-02-11-07-23-24.zip
etag: "5dfa5a9c-1a46922d"
strict-transport-security: max-age=15984000
x-frame-options: SAMEORIGIN
accept-ranges: bytes
PHP Notice:  Undefined variable: contentLength in phar:///usr/src/magento/magento-download-archive/bin/mda.phar/Download.php on line 165
Downloading from https://MAG003125809:[email protected]/products/downloads/file/magento-sample-data-1.9.1.0.zip
Does the remote file exist? File size is 0, cannot download

I think we should therefore make the preg_match check in https://github.com/sonassi/magento-download-archive/blob/master/src/Download.php#L158 case insensitive, by adding i:

if (preg_match('/Content-Length: (\d+)/i', $data, $matches))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant