1

I'm trying to pass a URL as a param to my Rails app:

Started DELETE "/images/0?s3_filepath=https://s3.amazonaws.com/buildinprogresstest/uploads/blllbyq5k3qinl4l/uploads_2F9qggxxf5dvlsor-667601c8f38d8d41af07828accbf3147_2F2014-07-13%252B18.44.29.jpg" for 127.0.0.1 at 2016-08-31 11:52:09 -0400

The s3_filepath is not being properly parsed in the params:

 Parameters: {"s3_filepath"=>"https://s3.amazonaws.com/buildinprogresstest/uploads/blllbyq5k3qinl4l/uploads_2F9qggxxf5dvlsor-667601c8f38d8d41af07828accbf3147_2F2014-07-13%2B18.44.29.jpg", "id"=>"0"}

If you look closely, the filename includes the sequence "252B18" but the params seems to remove the numbers "52"

I'm at a loss as to why this is happening. Any ideas?

1 Answer 1

1

Normally parameters are url-encoded and decoded on rails side. %25 is decoded to %, that's why it is removed from your input. You need to properly encode this url.

In Ruby you can use CGI.escape

CGI.escape "https://s3.amazonaws.com/buildinprogresstest/uploads/blllbyq5k3qinl4l/uploads_2F9qggxxf5dvlsor-667601c8f38d8d41af07828accbf3147_2F2014-07-13%252B18.44.29.jpg"
=> "https%3A%2F%2Fs3.amazonaws.com%2Fbuildinprogresstest%2Fuploads%2Fblllbyq5k3qinl4l%2Fuploads_2F9qggxxf5dvlsor-667601c8f38d8d41af07828accbf3147_2F2014-07-13%25252B18.44.29.jpg"

If you send this request via javascript you can use escape function in javascript

escape("https%3A%2F%2Fs3.amazonaws.com%2Fbuildinprogresstest%2Fuploads%2Fblllbyq5k3qinl4l%2Fuploads_2F9qggxxf5dvlsor-667601c8f38d8d41af07828accbf3147_2F2014-07-13%25252B18.44.29.jpg")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.