Skip to content

Listing S3 objects with space or unicode characters in the key fails #703

@kerryjj

Description

@kerryjj

Environment

  • Elixir & Erlang versions (elixir --version):
    Erlang/OTP 21 [erts-10.3.5.11] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
    Elixir 1.8.2 (compiled with Erlang/OTP 21)

  • ExAws version mix deps |grep ex_aws
    2.1.3

  • HTTP client version. IE for hackney do mix deps | grep hackney
    1.15.2

Current behavior

When using ExAws.S3.list_objects_v2 or ExAws.S3.list_objects and a key that has a space or unicode chars in it, the query params passed to S3 are double encoded.

The following command fails because the URL signatures don't match. This is because the query prefix is encoded to replace " " with +. Then the sanitize method replacces + with %2B.

ExAws.S3.list_objects_v2("my-bucket", prefix: "Copy ") |> ExAws.request()
ExAws: Request URL: "https://s3.eu-west-1.amazonaws.com/my-bucket/?list-type=2&prefix=Copy%2B" 

Expected behavior

ExAws.S3.list_objects_v2("my-bucket", prefix: "Copy ") |> ExAws.request()
ExAws: Request URL: "https://s3.eu-west-1.amazonaws.com/my-bucket/?list-type=2&prefix=Copy%20" 

I have a PR that shows a potential fix for this, so will include that here as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions