BZ-1009079 - Guided rule editor does not escape bad characters

(cherry picked from commit 51ba48ba2a1a8a27b51853df0b43505bde6febb0)