util: handle escaped forward slashes correctly

Fixes #6835