Convert ojbect to hash

Hi;

how can I convert such an object back to hash:
“{“uri”=>“http://172.16.35.228/row/SmallVideo.mp4”,
“chunklen”=>“3”, “requestid”=>“560”}”
tnx

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn http://ir.linkedin.com/in/taleghani

On Mon, Apr 21, 2014 at 2:08 PM, [email protected]
[email protected] wrote:

“{“uri”=>“http://172.16.35.228/row/SmallVideo.mp4”, “chunklen”=>“3”,
“requestid”=>“560”}”

eval:

2.0.0p195 :001 > eval
“{“uri”=>“http://172.16.35.228/row/SmallVideo.mp4”,
“chunklen”=>“3”, “requestid”=>“560”}”
=> {“uri”=>“http://172.16.35.228/row/SmallVideo.mp4”,
“chunklen”=>“3”, “requestid”=>“560”}

The usual caveats about security, caution about malicious user input,
etc apply:

2.0.0p195 :004 > eval
“{“uri”=>“http://172.16.35.228/row/SmallVideo.mp4”,
“chunklen”=>“3”, “requestid”=>“560”}; system(“echo ‘this
could have been rm -rf *’”)”
this could have been rm -rf *

Jesus.

:slight_smile: perfect!

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn http://ir.linkedin.com/in/taleghani

On Mon, Apr 21, 2014 at 4:43 PM, Jesús Gabriel y Galán <

Please do not top post.

On Mon, Apr 21, 2014 at 2:20 PM, [email protected]
[email protected] wrote:

:slight_smile: perfect!

Well, not quite: you should at least be aware of the security
implications of using eval. This will happily evaluate whatever Ruby
code is handed to it. If you get this string from some external
source and do not verify the format you program is wide open to abuse.

Kind regards

robert

actually they was HTTP/GET params that I had received via a web service
implemented via sinatra…
by the way, thanks cos of your point!

Regards,
Ali R. Taleghani
+1(424) 279-4548
@linkedIn http://ir.linkedin.com/in/taleghani

On Mon, Apr 21, 2014 at 10:19 PM, Robert K.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs