From fa7f89a400c80518a0153734a55232f7ce25661a Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 21 Mar 2017 14:48:24 -0400 Subject: [PATCH] Properly escape start and end regexes --- runtime/syntax/syntax_converter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/syntax/syntax_converter.go b/runtime/syntax/syntax_converter.go index 5e446ac3..e9f4dac0 100644 --- a/runtime/syntax/syntax_converter.go +++ b/runtime/syntax/syntax_converter.go @@ -148,8 +148,8 @@ func generateFile(filetype, syntax, header string, rules []interface{}) string { output += fmt.Sprintf(" - %s: \"%s\"\n", rule.color, strings.Replace(strings.Replace(rule.regex, "\\", "\\\\", -1), "\"", "\\\"", -1)) } else if rule, ok := r.(MultiRule); ok { output += fmt.Sprintf(" - %s:\n", rule.color) - output += fmt.Sprintf(" start: \"%s\"\n", rule.start) - output += fmt.Sprintf(" end: \"%s\"\n", rule.end) + output += fmt.Sprintf(" start: \"%s\"\n", strings.Replace(strings.Replace(rule.start, "\\", "\\\\", -1), "\"", "\\\"", -1)) + output += fmt.Sprintf(" end: \"%s\"\n", strings.Replace(strings.Replace(rule.end, "\\", "\\\\", -1), "\"", "\\\"", -1)) output += fmt.Sprintf(" rules: []\n\n") } }