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

Provide an ASCII fallback for multibyte filenames #1453

Merged
merged 8 commits into from
Aug 9, 2022
Merged

Provide an ASCII fallback for multibyte filenames #1453

merged 8 commits into from
Aug 9, 2022

Conversation

kamil4
Copy link
Contributor

@kamil4 kamil4 commented Aug 8, 2022

Fixes #1452

An equivalent of an old fix we had implemented for albums in #384

@kamil4 kamil4 requested a review from a team August 8, 2022 21:19
@codecov
Copy link

codecov bot commented Aug 8, 2022

Codecov Report

Merging #1453 (8da77f2) into master (fe173e4) will decrease coverage by 0.25%.
The diff coverage is 100.00%.

Copy link
Collaborator

@nagmat84 nagmat84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good. I also compared it with the analogous code for the albums to ensure consistency, i.e.

$disposition = HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_ATTACHMENT,
$zipTitle . '.zip',
mb_check_encoding($zipTitle, 'ASCII') ? '' : 'Album.zip'
);

Let's see, if I find the time to add a test case this evening so that we won't tumble across this regression a third time. Or you can add it. It shouldn't be too difficult. Just upload a photo, rename it to something with multi-byte characters in it and then download it. Optimally, we also add a test for an album, too, while we are on it.

Copy link
Member

@ildyria ildyria left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@kamil4
Copy link
Contributor Author

kamil4 commented Aug 9, 2022

Strictly speaking, we don't need a new image file with a multi-byte character; we could just upload one of the existing ones and then change the title. But I guess there may be value in testing multi-byte uploads as well...

I agree with @nagmat84 that we should also add a test for multi-byte album downloads.

@kamil4
Copy link
Contributor Author

kamil4 commented Aug 9, 2022

Looking through the testsuite, I could easily add a relevant album test by adding just a couple of lines to testManyFunctionsAtOnce, around:

$this->albums_tests->download($albumID);

Is that considered acceptable? There's a comment at the start of that method that says: Preferably, all the tested actions should be seperated into individual tests.

Copy link
Collaborator

@nagmat84 nagmat84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will push some commits myself which address my remarks.

tests/TestCase.php Outdated Show resolved Hide resolved
tests/Feature/PhotosMultiBytesTest.php Outdated Show resolved Hide resolved
tests/Feature/PhotosMultiBytesTest.php Outdated Show resolved Hide resolved
@nagmat84
Copy link
Collaborator

nagmat84 commented Aug 9, 2022

Strictly speaking, we don't need a new image file with a multi-byte character;

That's what I thought of, too.

we could just upload one of the existing ones and then change the title. But I guess there may be value in testing multi-byte uploads as well...

Agreed. And as @ildyria has already added a sample file, I'm fine with that.

@nagmat84
Copy link
Collaborator

nagmat84 commented Aug 9, 2022

Looking through the testsuite, I could easily add a relevant album test by adding just a couple of lines to testManyFunctionsAtOnce, around:

$this->albums_tests->download($albumID);

Is that considered acceptable? There's a comment at the start of that method that says: Preferably, all the tested actions should be seperated into individual tests.

I would like to avoid that. When I added a lot of test as part of #1351, I needed to get this "god test" out of my way but did not want to lose what has already been there. In the long run this god test should be split, hence I would prefer not to add to that mess.

Let's see if I can create a test this evening.

Copy link
Collaborator

@nagmat84 nagmat84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all my concerns myself. I also added a test to download an archive with a multi-byte title. Feel free to merge and resolve my remarks. I only left them open for you such that they are more easily to read.

@kamil4 kamil4 merged commit 420beb4 into master Aug 9, 2022
@kamil4 kamil4 deleted the fix-1452 branch August 9, 2022 20:36
@nagmat84 nagmat84 mentioned this pull request Aug 10, 2022
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

Successfully merging this pull request may close these issues.

Error 500 when downloading an image with non-ASCII characters
3 participants