Warning: os.path.join surprising behaviour

>>> os.path.join("/a/b/c", "/d/e/f")
"/d/e/f"

This can be a problem if “/d/e/f” comes from an untrusted source.

As a safety measure, avoid using os.path.join in your web applications, roll your own and call it “safe_join”. You will sleep better.


About this entry