-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Clean up export filenames for Excel compatibility #22969
base: 5.x-dev
Are you sure you want to change the base?
Conversation
Tested the new function locally, can confirm that the new function behaves as expected. Was unable to replicate the wider issue on my Windows machine, my version of excel seems to handle these filenames correctly. |
["control\x00\x09\x0A\x7Fcharacters", 'controlcharacters'], | ||
[' spaces are trimmed ', 'spaces are trimmed'], | ||
['unicode spaces', 'unicode spaces'], | ||
['unicode‒–—dashes', 'unicode---dashes'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a couple more tests, such as a legal file name that isn't changed, and other special characters such as multi-byte unicode characters, like Chinese?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some examples generated from the report export feature. Let me know if there are any more variants/special characters we should add.
core/Filesystem.php
Outdated
|
||
// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file | ||
$filename = preg_replace('~[<>:"/\\\\|?*]~', '', $filename); | ||
$filename = preg_replace('~\p{Cc}~u', '', $filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps another comment explaining what these Regex statements mean, more than just a link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More links and comments added 👍
Description:
The current (CSV) exports can contain unicode characters like
&thsp;
("thin space"), preventing them from being openend in some programs like Excel.A replacement of "special dashes" and "special whitespace" with their ASCII representation should fix that problem. Additionaly some other reserved characters like
<>
are now being removed from both report exports and scheduled report email attachment filenames.Refs DEV-18832
Review