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

Spaces swallowed on file upload in UI #1741

Open
Bloke opened this issue Oct 8, 2021 · 2 comments
Open

Spaces swallowed on file upload in UI #1741

Bloke opened this issue Oct 8, 2021 · 2 comments

Comments

@Bloke
Copy link
Member

Bloke commented Oct 8, 2021

This isn't a bug, per se, but does lead to unexpected behaviour under certain circumstances.

STR:

  1. Prepare a file for upload with the filename:
    This is a test.txt (note: there are two spaces between 'a' and 'test').
  2. Upload via Content>Files.
  3. Note that the success message says that the file "This is a test.txt" (one space) has been uploaded successfully. And it's shown with one space in the file download list and on the file details panel. All good.
  4. Tapping to Download (hover over it) the file shows that the double space is preserved as a '++' in the file download link. Similarly, if you use the Textile/Tag/HTML tag builder, they contain the proper double spacing.
  5. If you are not aware of this and want to use the file in a shortcode (say) or a file_download tag to attach it to an article as a download, the user may go to the Files panel and simply copy the filename (with one space) as shown on-screen and plug it into the tag:
    <txp:file_download filename="This is a test.txt" />
  6. This leads to the file_download tag failing because it cannot find that file in the filesystem.

This is an ultra, ultra corner case and I don't think there's anything we can do about it. But if anyone has any clever ideas on the best approach (pass filename through a regex on upload to swallow multiple spaces and use that when we move_ulpoaded_file?) then it might be handy.

This has just happened on a live site and the admin there sent me a request asking why his download tag wasn't working!

@petecooper
Copy link
Member

In a similar vein:

                               .png

(32 space characters) is saved/downloaded as png, minus the ., for hyper corner case points.

It appears GitHub Markdown truncates double spaces in inlined code.

@Bloke
Copy link
Member Author

Bloke commented Oct 8, 2021

Hmmmm yeah. Not sure if this is a problem or not. I mean, there isn't much we can do about it short of stripping some/all/double spaces on upload, which changes a user's filename and thus might be construed as meddling. I can't really see a reason for double spaces in a filename, but, y'know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants