<div class="gmail_quote">On 11 September 2011 22:59, Platonides <span dir="ltr"><<a href="mailto:platonides@gmail.com">platonides@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Also, I'm not sure if urllib.open() works with file:// urls, but I'd</div>
verify it's a http or https url .<br>
<div><div></div><div class="h5"><br></div></div></blockquote><div><br></div><div>It even works without. For urllib2, you do need to use file:// urls.</div><div><br></div><div>valhallasw@dorthonion:~$ python</div><div>Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)</div>
<div>[GCC 4.4.3] on linux2</div><div>Type "help", "copyright", "credits" or "license" for more information.</div><div>>>> import urllib, urllib2</div><div>>>> urllib.urlopen('/etc/passwd').readlines()</div>
<div>['root:x:0:0:root:/root:/bin/bash\n', (...) ,'usbmux:x:109:46:usbmux daemon,,,:/home/usbmux:/bin/false\n']</div><div><div>>>> urllib2.urlopen('file:///etc/passwd').readlines()</div><div>
['root:x:0:0:root:/root:/bin/bash\n', (...)</div></div><div><br></div><div>Of course, it all boils back to the old motto 'never trust user input' - and be sure standard libraries are not more general than you think... </div>
<div><br></div><div>(and this is something that might have bitten more of us, including me :-))</div><div><br></div><div>Best,</div><div>Merlijn</div></div>