Escape filenames in regexes. Fixes #942.