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

fileserver: grid view - preview img src attribute is not URL query-escaped #6237

Closed
DenebTM opened this issue Apr 12, 2024 · 3 comments
Closed
Labels
bug 🐞 Something isn't working
Milestone

Comments

@DenebTM
Copy link
Contributor

DenebTM commented Apr 12, 2024

In the grid view of the file browser's default template, if the filename of an image contains the characters # or ?, the preview doesn't appear, since web browsers (at least Firefox and Chromium) parse the src attribute as an URL. The href attribute pointing to the file itself is unaffected, so it remains possible to click on these files to open them, only the preview is broken.

@DenebTM DenebTM changed the title fileserver: grid view - img src tag is not URL query-escaped fileserver: grid view - preview img src attribute is not URL query-escaped Apr 12, 2024
DenebTM added a commit to DenebTM/netdeneb that referenced this issue Apr 12, 2024
@mholt mholt closed this as completed in 5d8b45c Apr 12, 2024
@mholt
Copy link
Member

mholt commented Apr 12, 2024

Thanks! Fixed.

@mholt mholt added the bug 🐞 Something isn't working label Apr 12, 2024
@mholt mholt added this to the v2.8.0 milestone Apr 12, 2024
@DenebTM
Copy link
Contributor Author

DenebTM commented Apr 13, 2024

Oh nice, that was fast! Two things though.

  1. A literal % needs to be encoded as %25, else any filename containing a percent followed by hexadecimal digits will break. And although it doesn't seem to be an issue, & should be encoded as %26 for completeness' sake.

  2. Tbh I was kind of anticipating less of a "quick and dirty" fix than my own lol. It seems to me that a custom function wrapping Go's url.PathEscape should be added to the template module, since the closest built-in function urlquery from text/templates isn't quite suitable for escaping paths.

@mholt
Copy link
Member

mholt commented Apr 13, 2024

I actually thought the html template action would escape accordingly based on context, but I guess that doesn't work.

I didn't reference any other implemention, only just now saw that you pushed some of your own commit elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants