Add helper to sanitize strings used as file name
(cherry picked from commit d37384a4da702d87b3df74505fa9482c186482a0)