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

Fix SupportFileDownloads - Multibyte character support #6553

Merged

Conversation

nxsdev
Copy link
Contributor

@nxsdev nxsdev commented Aug 27, 2023

1️⃣ Is this something that is wanted/needed? Did you create a discussion about it first?
Yes
#4946
This is not a discussion I created, but another person put it up.
2️⃣ Did you create a branch for your fix/feature? (Master branch PR's will be closed)
Yes
3️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
No
4️⃣ Does it include tests? (Required)
Yes
5️⃣ Please include a thorough description (including small code snippets if possible) of the improvement and reasons why it's useful.

if (preg_match('/filename\*=utf-8\'\'(.+)$/i', $header, $matches)) {
    return rawurldecode($matches[1]);
}

I added the above code to livewire/src/Features/SupportFileDownloads.php above. Currently, there was a problem that file names containing Japanese characters would end up as ______.csv when trying to download them. We believe this needs to be fixed, especially since Livewire is a very popular library in Japan.
We have improved the problem by adding a decoding process in the case of filename*, and confirmed that it works with UnitTest.

I have tested this modification on Laravel in the following environment
PHP 8.2.9
Laravel 10.22.0

#4946
I tested with Ελληνικά.xlsx and Japanese ダウンロード.csv in the same situation as

Before the modification, as shown below, ________.xlsx and ______.csv with multibyte characters did not download with the correct file name.

Image from Gyazo

With this correction, we can confirm that we were able to download the file with the correct file name.
Below is a screenshot of the corrected file.

Image from Gyazo

@nxsdev nxsdev changed the title Fix SupportFileDownloads Fix SupportFileDownloadsForJapanese Aug 27, 2023
@nxsdev nxsdev changed the title Fix SupportFileDownloadsForJapanese Fix SupportFileDownloads - Japanese language support Aug 28, 2023
@nxsdev nxsdev changed the title Fix SupportFileDownloads - Japanese language support Fix SupportFileDownloads - Multibyte character support Aug 28, 2023
@nxsdev nxsdev force-pushed the fix/japanese-filename-discussion-4946 branch from 52a3808 to a7dc0a6 Compare August 29, 2023 14:49
@PhiloNL PhiloNL changed the title Fix SupportFileDownloads - Multibyte character support [V3] Fix SupportFileDownloads - Multibyte character support Aug 30, 2023
@nxsdev
Copy link
Contributor Author

nxsdev commented Sep 4, 2023

It appears that you need to get approval from the maintainer. Can anyone help me get approval?

@joshhanley joshhanley changed the title [V3] Fix SupportFileDownloads - Multibyte character support Fix SupportFileDownloads - Multibyte character support Sep 8, 2023
@calebporzio
Copy link
Collaborator

Thanks!

@calebporzio calebporzio merged commit 99e2933 into livewire:main Sep 13, 2023
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants