Skip to content

[5.8] Fix exception: The filename fallback must only contain ASCII characters. - #28551

Merged
taylorotwell merged 7 commits into
laravel:5.8from
SymfonyRotEbal:fix_the_filename_fallback_must_only_contain_ascii_characters
May 17, 2019
Merged

taylorotwell merged 7 commits into
laravel:5.8from
SymfonyRotEbal:fix_the_filename_fallback_must_only_contain_ascii_characters

Conversation

@4n70w4

@4n70w4 4n70w4 commented May 16, 2019

Copy link
Copy Markdown
Contributor

Generate and pass $filenameFallback param to \Symfony\Component\HttpFoundation\HeaderUtils::makeDisposition().

Problem: downloading files with Cyrillic names does not work. Test complete.
\Illuminate\Tests\Filesystem\FilesystemAdapterTest::testDownloadNonAsciiFilename()

Comment thread tests/Filesystem/FilesystemAdapterTest.php Outdated
@driesvints driesvints changed the title fix exception: The filename fallback must only contain ASCII characters. [5.8] Fix exception: The filename fallback must only contain ASCII characters. May 16, 2019
@4n70w4

4n70w4 commented May 16, 2019

Copy link
Copy Markdown
Contributor Author

@driesvints thanks, I improved the test!

@4n70w4

4n70w4 commented May 16, 2019

Copy link
Copy Markdown
Contributor Author

Related: #2703 #2305 #28369

@taylorotwell

Copy link
Copy Markdown
Member

$name defaults to null. So you are passing Str::ascii(null) potentially? I feel like we aren't thinking this issue through every time we get an issue or PR about it.

@4n70w4

4n70w4 commented May 16, 2019 •

Copy link
Copy Markdown
Contributor Author

@taylorotwell thank you, I did not think about it. I fix it!

$response = new StreamedResponse;

$disposition = $response->headers->makeDisposition($disposition, $name ?? basename($path));
$target_name = $name ?? basename($path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$target_name camelCase 😃

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fragkp continuous-integration/styleci/pr says that everything is ok. camelCase is this private requirement?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering why stylci is not failing. camelCase is the default for variable names in laravel. You could check this in all other files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

StyleCI cannot fail for those cases, because it is not possible to fix such cases without breaking dynamic code. There are also various special cases where snake case is needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, I fixed it.
But need to fix the automatic codestyle verification.
External developers don't know your local codestyle rules.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But need to fix the automatic codestyle verification.

As I said, it is not broken. It is inherently not possible to safely rename variables.

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.

5 participants