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

Filename sanitization rules are inconsistent #6465

Closed
silllli opened this issue Jun 3, 2024 · 6 comments
Closed

Filename sanitization rules are inconsistent #6465

silllli opened this issue Jun 3, 2024 · 6 comments

Comments

@silllli
Copy link
Contributor

silllli commented Jun 3, 2024

As a followup from the other issue. I added the following comment, which probably got lost:

I found another inconsistency between server and client side. Str::slug() which is used by F::safeBasename() does

// trim leading and trailing non-word-chars

and uses a-z0-9 in its regex pattern on the server (source). The slug helper in the panel Vue code on the other hand, which should also

// trim leading and trailing non-word-chars

uses the passed allowed character set (new RegExp('^[^' + allowed + ']+', 'g')) in its regex pattern (source).

So you can enter something like _test.jpg in the panel when renaming and uploading a file, but the file will be saved as test.jpg.

Since the panel can’t handle files starting with underscores (for some reason) I would opt to use the more restrictive pattern.

@distantnative
Copy link
Member

It's hasn't gotten lost. Let's keep it with one issue for this.

@distantnative distantnative closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
@silllli
Copy link
Contributor Author

silllli commented Jun 3, 2024

The other issue was and remains closed as “completed” (after me stating more inconsistencies), so I thought there is need for a new one to stay visible.

@distantnative
Copy link
Member

@silllli as far as I see the PR #6462 does address those as well or do you see its differently?

@silllli
Copy link
Contributor Author

silllli commented Jun 3, 2024

@distantnative Ah, true! But using the passed allowed character set is prone to becoming out of sync with the sanitization on the server (which is hardcoded) again.

Also, as I mentioned, the Panel can’t handle files starting with an underscore (which was prevented so far) so there is a way to break it now by renaming a file to start with an underscore.

@distantnative
Copy link
Member

Which is why the PR also removes them on the Panel/frontend at the start/end of the filename.

@silllli
Copy link
Contributor Author

silllli commented Jun 3, 2024

Perfect. Sorry, I didn’t check all commits and there was no feedback on my additional comment.

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

No branches or pull requests

2 participants