Skip to content

Filenames for wiki pages with special characters #8410

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

Closed
Tekaoh opened this issue Oct 7, 2019 · 7 comments
Closed

Filenames for wiki pages with special characters #8410

Tekaoh opened this issue Oct 7, 2019 · 7 comments

Comments

@Tekaoh
Copy link
Contributor

Tekaoh commented Oct 7, 2019

Gitea currently saves wiki pages with special characters in the name as files that contain escaped characters in the name. (Example: Title with comma, ampersand & [brackets] = Title-with-comma%2C-ampersand-%26-%5Bbrackets%5D.md)

I propose that Gitea should be saving these pages as filenames with unescaped characters. (Example: Title with comma, ampersand & [brackets] = Title-with-comma,-ampersand-&-[brackets].md)

This would be better because sometimes these wikis are cloned and edited locally. Unescaped filenames are better for that. Also, other services like Github use unescaped characters and so any wikis mirrored from these services come with unescaped characters already. (See #8284 and #8408)

This would present a significant change because all the unit tests currently assume that filenames are saved with escaped characters. Also, backwards compatibility with existing wiki pages would be a concern. However, the unit tests could be adjusted and the solution presented in #8408 would solve the compatibility problem (with the logic reversed to satisfy the new unit tests).

For now, I'm hoping for feedback and discussion about this proposal. I'm also willing to prepare a pull request to make this change.

@bagasme
Copy link
Contributor

bagasme commented Oct 8, 2019

At least NTFS (on Windows) allows filenames with ,, &, and [ ], not sure about FAT file system.

However, consider the case when NTFS also forbids <, >, :, ", /, \ | ? and *. If any of those forbidden characters are present on wiki page file name, Gitea should throw Illegal characters on file name error (only when Gitea is installed in Windows).

@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 8, 2019

That's an interesting point. I wonder how Gitea handles cases of files in regular repositories with these illegal characters in the filenames. They could potentially be pushed from Linux machines or created in the web browser. Only filenames in wiki repositories seem to be escaped currently.

Also, I wonder what would happen if you tried on Windows to clone a wiki repo from Github that has pages with these characters in the titles since Github uses unescaped characters in wiki filenames. Although that's a curiosity of Git's behavior, not Gitea's.

@guillep2k
Copy link
Member

Consider repositories where you have:

MyFile.txt
myfile.txt
myFile.TXT
etc.

@Tekaoh
Copy link
Contributor Author

Tekaoh commented Oct 8, 2019

Those don't have special characters though, so escaping them is irrelevant. Since you're allowed to have those filenames on Linux, I wonder what would happen if you create them on Linux and push to Gitea running on Windows.

Gitea doesn't actually store the files, just Git trees. So those files in a repo wouldn't necessarily exist in the Windows filesystem even if Gitea is installed on Windows. That should actually be true of filenames with special characters that NTFS doesn't like as well, I think...

@bagasme
Copy link
Contributor

bagasme commented Oct 9, 2019

@Tekaoh And Git stores any repo data (including the wiki repo) as blob object with SHA-1 hash as blob's name. If you interested see explanations from Pro Git book.

Since the hash just contain 0-9 and a-f, the object can be stored anywhere, even on Windows (NTFS).

@lunny lunny added the type/bug label Oct 9, 2019
@stale
Copy link

stale bot commented Dec 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Dec 8, 2019
@stale
Copy link

stale bot commented Dec 22, 2019

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Dec 22, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants