refactoring: outsourced sanitize_string() from rst.py to util.py