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>
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.
···
On Mon, Apr 21, 2014 at 2:08 PM, shayne.alone@gmail.com <shayne.alone@gmail.com> wrote:
"{\"uri\"=>\"http://172.16.35.228/row/SmallVideo.mp4\", \"chunklen\"=>\"3\",
\"requestid\"=>\"560\"}"
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 < jgabrielygalan@gmail.com> wrote:
On Mon, Apr 21, 2014 at 2:08 PM, shayne.alone@gmail.com > <shayne.alone@gmail.com> 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.
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 Klemme <shortcutter@googlemail.com>wrote:
Please do not top post.
On Mon, Apr 21, 2014 at 2:20 PM, shayne.alone@gmail.com > <shayne.alone@gmail.com> wrote:
>
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
--
[guy, jim].each {|him| remember.him do |as, often| as.you_can - without
end}
http://blog.rubybestpractices.com/