-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Allow to display embed images/pdfs when SERVE_DIRECT was enabled on MinIO storage #35882
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
Conversation
|
As far as I know, this issue is specific to PDF LFS files. The Additionally, have we considered using |
|
What is the expected behavior if we rely on file extension name for LFS type detection and the extension name is wrong? Specifically, will the file content still be displayed correctly? |
For images, wrong mimetype still works. |
It depends on the client. Some like browsers can handle wrong mime type and do another content type detection based on the data. |
|
This is a quick fix for the "View Raw File" on the Web UI, which have the filename in the URL. So it should work. |
|
Why not just exclude |
Will you also remember to exclude |
Just use if mimetype == "application/pdf" || (strings.HasPrefix(mimetype, "image/") && mimetype != "image/svg+xml")We have similar code in other places already so it could be moved to a |
|
Also, what about audio/video files? See gitea/modules/typesniffer/typesniffer.go Lines 80 to 83 in 0ce7d66
|
I don't like it, it doesn't feel safe, I don't want to spend more time on fixing security bugs in the future. If you can fix the security problems when they appear in the future, feel free to make your changes. |
No, I don't want to use it at the moment. There are still more logic after This PR aims to fix the clear problems as it stated. To fix more, the comment keyword |
|
To fully refactor the related code and add more supports, it needs to use the approach from "Fix mime-type detection for HTTP server (#18370)" (and also refactor the existing code, a lot of changes) Then it will introduce much more changes in this PR. I don't think these works need to be in this PR's scope (since this PR's aim is clear) |
|
I think this will work as a quick fix, but it would be better to define a |
|
I think this can be merged so that it will be easier to backport to v1.25. |
I think this PR's code is clear, safe, and well-commented, its logic is complete for its goal and doesn't make any blocker for future refactoring. I don't see a must to do more changes. If you have ideas about making more changes, feel free to edit it directly. |
* giteaofficial/main: Allow to display embed images/pdfs when SERVE_DIRECT was enabled on MinIO storage (go-gitea#35882) Add proper page title for project pages (go-gitea#35773) Use correct form field for allowed force push users in branch protection API (go-gitea#35894) Fix team member access check (go-gitea#35899) Add ability for local makefile with personal customizations that wouldnt affect remote repo (go-gitea#35836) Add toolchain directive to go.mod (go-gitea#35901) Display source code downloads last for release attachments (go-gitea#35897) Fix conda null depend issue (go-gitea#35900) Fix avatar upload error handling (go-gitea#35887) Move `gitea-vet` to use `go tool` (go-gitea#35878) Contribution heatmap improvements (go-gitea#35876) Update to go 1.25.4 (go-gitea#35877)
Releated issue: #30487