I think we can just use `escape_javascript` instead of `gsub`. Search for `escape_javascript` in our codebase to see how it's used.