Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Replace illegal characters in file extension #988

wants to merge 2 commits into


None yet
3 participants

We found issues with paperclip when the image file extension contains colon, eg: https://p.twimg.com/AzvR1RsCUAEhBhV.jpg:large

This is very common for twitter images. In our case, it caused an error in ImageMagick identify when checking the image dimensions via image.queued_for_write[:original] before saving it.

The command was failing since bash was getting confused with the .jpg:large[0].

This replaces any colons in the extension with underscores.

This pull request fails (merged 508a93d into 70f0f1f).

This pull request fails (merged f85be6e into 70f0f1f).

Can anyone help debug these test failures? Testing locally, even when reverting my changes, these tests still fail. Does anyone know of any flakyness around that?


jyurek commented Aug 24, 2012

@felipecsl I think the problem here is the result of HFS using colons as path separators, right? Why does this problem only affect extensions? Might it be the case that filenames themselves are affected?

@jyurek as far as I can tell, the filename is already being cleaned up by Attachment#cleanup_filename, so any colons there are already being replaced. However, there was no cleaning up for the file extension, which is where I was having issues.


jyurek commented Oct 19, 2012

The problem is that the cleanup_filename happens after the file has been processed, which means that the command line gets to it before the cleanup_filename method.

I've committed a fix for this in master (83d8ec5), and it should solve the problem. I'm going to close this, but if this doesn't work please let me know.

@jyurek jyurek closed this Oct 19, 2012

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