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(files): disallow illegal characters #40585

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

skjnldsv
Copy link
Member

fix #38614

@skjnldsv skjnldsv self-assigned this Sep 22, 2023
@skjnldsv skjnldsv added this to the Nextcloud 28 milestone Sep 22, 2023
@skjnldsv skjnldsv force-pushed the feat/f2v/dnd branch 4 times, most recently from 9ef05d6 to e3b2af4 Compare September 26, 2023 18:22
Base automatically changed from feat/f2v/dnd to master September 26, 2023 18:33
@skjnldsv skjnldsv requested review from a team, susnux, Pytal, szaimen and artonge and removed request for a team September 26, 2023 18:46
@susnux
Copy link
Contributor

susnux commented Sep 26, 2023

I disagree here, just because one system (Window) can not handle those symbols we should not hard forbid it here.
E.g. I often use some of those.

See also the git blame of OCP\Constants::FILENAME_INVALID_CHARS.

Especially we should not have multiple different character lists that we forbid, I would simply use OCP\Constants::FILENAME_INVALID_CHARS and maybe make if configurable to forbid more (system config value?)

@skjnldsv
Copy link
Member Author

skjnldsv commented Sep 27, 2023

See also the git blame of OCP\Constants::FILENAME_INVALID_CHARS.

Especially we should not have multiple different character lists that we forbid, I would simply use OCP\Constants::FILENAME_INVALID_CHARS and maybe make if configurable to forbid more (system config value?)

Nice, I search for this, and I could only find a variable in files_external, which would ot have been proper to use.

I disagree here, just because one system (Window) can not handle those symbols we should not hard forbid it here.

I don't think that's a big of an issue to be honest, but I agree with you.
What shall we do then? Close the other issue?

EDIT

BTW, linux have a bit more than just /
https://stackoverflow.com/a/31976060/3885878

Also, it seems many people do recommend to refrain from using some.

EDIT2

Do we actually support windows officially? If not, I would then close the other issue.
The only option I see if adding a config variable so people can use it 🤔
cc @ChristophWurst @nickvergessen @juliushaertl @icewind1991

@nickvergessen
Copy link
Member

Do we actually support windows officially?

Not as server plattform.

But it's of course still bad UX when people create such files on ubuntu/mac and then share with windows users.

The list you have matches the old value of the constant:
6bd0d51

So I would say the only disallowed chars are / and \ so you can use the const.

Some external storages have more restrict limits (SMB?), but I'd say it's fine to not block that in the UI in the beginning and just show an error afterwards.

@skjnldsv
Copy link
Member Author

skjnldsv commented Oct 4, 2023

So I would say the only disallowed chars are / and \ so you can use the const.

The const is a weird format though. It should be an array of string, not a string...
Especially the var name is confusing, being plural 🙈

@nickvergessen
Copy link
Member

It should be an array of string, not a string...

We have been growing a long way. It simply was not allowed in PHP until 5.6
grafik

@skjnldsv
Copy link
Member Author

skjnldsv commented Oct 4, 2023

Done! Please review :)

@skjnldsv skjnldsv removed the 2. developing Work in progress label Oct 4, 2023
@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Oct 4, 2023
config/config.sample.php Show resolved Hide resolved
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
@skjnldsv skjnldsv merged commit 529bce2 into master Oct 4, 2023
38 of 39 checks passed
@skjnldsv skjnldsv deleted the fix/illegal-characters branch October 4, 2023 09:27
@susnux
Copy link
Contributor

susnux commented Oct 4, 2023

Very nice solution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug feature: files
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Disallow illegal characters / ? < > \ : * | " and so on in file and folder names
5 participants