util: handle escaped forward slashes correctly

Fixes #6835
Merge remote-tracking branch 'upstream/master'