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

long filenames can cause 500 exception #388

Open
stefanfoulis opened this issue Nov 9, 2015 · 3 comments
Open

long filenames can cause 500 exception #388

stefanfoulis opened this issue Nov 9, 2015 · 3 comments

Comments

@stefanfoulis
Copy link
Contributor

when trying to save the cached thumbnail database entry, it is possible that a 500 error is raised (because the 255 character limit may be exceeded at database level).

@zsoobhan
Copy link

zsoobhan commented Jul 6, 2016

As far as I can tell, this happens because the processors are allowed to make the filenames as long as they want to without going through any checks. Was there a workaround?

zsoobhan pushed a commit to pancentric/easy-thumbnails that referenced this issue Jul 6, 2016
Changes the max_length on the File.name from 255 to 1023
Adds:
  - django migration
  - south migration
zsoobhan pushed a commit to pancentric/easy-thumbnails that referenced this issue Jul 6, 2016
Changes the max_length on the File.name from 255 to 1023
Adds:
  - django migration
  - south migration
zsoobhan pushed a commit to pancentric/easy-thumbnails that referenced this issue Jul 6, 2016
Changes the max_length on the File.name from 255 to 1023
Adds:
  - django migration
  - south migration
zsoobhan pushed a commit to pancentric/easy-thumbnails that referenced this issue Jul 13, 2016
Changes the max_length on the File.name from 255 to 1023
Adds:
  - django migration
  - south migration
@stefanfoulis
Copy link
Contributor Author

stefanfoulis commented Jul 15, 2016

In my case it was simply avoiding long source filenames.
But there might be database backends that don't like charfields longer than 255. I'm not sure and my information might be outdated. But I remember having problems with that (many years ago). I think on mysql.

@zsoobhan
Copy link

zsoobhan commented Jul 15, 2016

Hmm, good point. I had a quick search of the supported database backends and found the following:

Backend Support
Oracle 11.1 4000 bytes (1024 - 4096 chars)
Postgres 9.5 1 GB
MySQL 65,535 Chars

I'm not sure of the specifics for each versions of the database backends. On a side note, Django restricts the max_length of VARCHAR fields to 255 when used as unique fields which suggests that it might be best practice to leave it at that?

In any case, I wrote a quick .js script to validate the input from the user and upped the limit on the field since I am using Postgres, but I thought it would be good to have this information somewhere on the web. Here's the pull request: #414


Sources

https://www.postgresql.org/docs/9.5/static/datatype-character.html
https://docs.oracle.com/cd/B28359_01/server.111/b28320/limits001.htm
http://dev.mysql.com/doc/refman/5.7/en/char.html
https://docs.djangoproject.com/en/dev/ref/databases/#character-fields

LePetitTim added a commit to LePetitTim/easy-thumbnails that referenced this issue May 22, 2020
- Do not use hash for SEO
- Truncate end of the file after generate thumbnail
- Add tests with long names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants