Add the Addressable gem to more responsibly parse uris. #337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request attempts to resolve the concerns raised in this issue: #336
In a nutshell, the issue is that the URI library—specifically the URI.escape method—does not accept all possible, and valid URIs. The particular problem I was having when I raised the issue was that I had users uploading files with file names that included square brackets.
A lot of google searching later, and I found the following:
I also found looking in the carrierwave source this pull-request and commit: https://github.com/carrierwaveuploader/carrierwave/pull/1013/files#diff-323aa4ff2c24aebdbdd5f21fb1195886R75 which attempt to solve the exact same problem.
Personally, I don't think that's the best solution as it's still using the deprecated URI.encode method.
I'm not sure how you feel about introducing another dependency for the project, but it looks like that might be the best solution.
I think that the Addressable gem might be nice to integrate throughout the gem, but rather than including that work into this pull request, I tried to localize my implementation to just this one particular place that solves this one particular problem, hence my returning the result of URI.parse, instead of converting those URI.parse's into Addressable::URI.parse's throughout.
Thoughts?