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

(cherry picked from commit 77cde239bdb8a762f225708d206273bae5d90b67)