Skip to content

CarrierWave::Downloader::Base#process_uri changes + to %2B in the path, breaking valid URLs #2800

@Cremesis

Description

@Cremesis

I am running into an issue with CarrierWave::Downloader::Base#process_uri where a valid URL becomes invalid after CarrierWave processes it.

The URL I provide is not encoded. It contains a literal + in the path. That + is valid for this server and must remain a literal +. However, CarrierWave’s URI processing converts it to %2B, and the resulting URL returns 404 Not Found.

Example:

Input URL (works):
https://pokemoncardimages.pokedata.io/images/Red+Flash/016.webp

URL after CarrierWave processing (fails):
https://pokemoncardimages.pokedata.io/images/Red%2BFlash/016.webp

Because of this, assigning something like:

model.remote_image_url = 'https://pokemoncardimages.pokedata.io/images/Red+Flash/016.webp'

ends up raising:

could not download file: 404 "Not Found"

To work around the problem I currently have a monkey patch for process_uri that normalizes using Addressable::URI while preserving the + in the path, but I would prefer not to patch CarrierWave internals.

Would you consider adjusting process_uri so that it does not percent-encode + characters in the path (or otherwise preserves the original path when it is already a valid URI for HTTP requests)?

I can provide a minimal reproduction if needed.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions