I want to let a user of a web app enter a URL and then pass that URL onto curl. I'd rather use curl than Net::HTTP or open-uri. But this poses a security risk. What's the best way to check the URL string and prevent any injection attacks?
I'm thinking of just using a regular expression like this to check for an injection attack:
raise "possible injection attack" if url =~ /[\s']/
and if that check succeeds, then just invoke curl like so
html = `curl '#{url}'`
Is this safe enough?