How to deal with the # character in filenames ? #203

Closed
artscoop opened this Issue Feb 12, 2013 · 9 comments

Comments

Projects
None yet
2 participants
Contributor

artscoop commented Feb 12, 2013

Hello.
Using the thumbnail tag with omething like replace_alpha="#fff" generates a file containing a hash character, which should not exist. How can I generate a proper escaped file name ?
Thanks

Owner

SmileyChris commented Feb 12, 2013

Well, the hash character is still valid in a filename, and the backend should be escaping it (I'm actually specifically checking for a '#' in filename and urlquoting it if one exists) -- see files.py, line 219.

Are you actually seeing a problem somewhere with this?

Contributor

artscoop commented Feb 13, 2013

Actually, yes, I have a problem.
I use the thumbnail template tag, with replace_alpha="#fff"
The filename generated uses the parameter, so that the file name ends with replace_alpha-#fff.png
The problem is that nginx cannot serve such a file, since everything after the dash is considered as a page anchor, and the tag returns an url which is not escaped by default. (I use the latest version from github)

Contributor

artscoop commented Feb 13, 2013

The picture is displayed, however, if I use the urlencode template filter.

Owner

SmileyChris commented Feb 13, 2013

thumb.url should be encoding the url already. How are you trying to render it?

Contributor

artscoop commented Feb 13, 2013

I'm using it this way :
{% thumbnail user|picture size radius=radius replace_alpha="#fff" as thumb %}
(or thumb.url)

Owner

SmileyChris commented Feb 13, 2013

Hrm, I'm confounded as to how {{ thumb.url }} wouldn't be escaping it correctly...

Contributor

artscoop commented Feb 13, 2013

It might be good to say that in the template, user|picture returns a path, not an instance of ThumbnailerField or something.

Owner

SmileyChris commented Jun 24, 2013

Pretty sure this is fixed now

Contributor

artscoop commented Jun 29, 2013

True. Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment