Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

[In the spirit of elucidation, and not general meanness…]

Like jojo14 points out Python has the shlex module, and it is definitely useful in these situations even if just for quote(). And, os.system() is basically never safe with external input. Without proper escaping you're one click from code execution, for example with the input "file:///etc/issue%3Becho%20whoops" or "http://example.com/';echo whoops'".

It doesn't appear to matter in this instance, but you can feed check_output() with the stdin argument, which removes the need for using shell=True. shell=True in other paths could easily lead to unwanted code execution without thorough escaping.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: