Fix broken safe_open() when path contains double slashes.
(cherry picked from commit ed36f31a54950a2778f380a9c3606502120ba647)
Merge pull request #1130 from kacfengine/3.5.x

[3.5.x] Fix broken safe_open() when path contains double slashes.