mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-06 10:04:43 +08:00
Add test for string escape bug and implement fix
Co-authored-by: mikefarah <1151925+mikefarah@users.noreply.github.com>
This commit is contained in:
committed by
Mike Farah
co-authored by
mikefarah
parent
b7cbe59fd7
commit
7f60daad20
@@ -614,9 +614,14 @@ func (te *tomlEncoder) colorizeToml(input []byte) []byte {
|
||||
if ch == '"' || ch == '\'' {
|
||||
quote := ch
|
||||
end := i + 1
|
||||
for end < len(toml) && toml[end] != quote {
|
||||
if toml[end] == '\\' {
|
||||
end++ // skip escaped char
|
||||
for end < len(toml) {
|
||||
if toml[end] == quote {
|
||||
break
|
||||
}
|
||||
if toml[end] == '\\' && end+1 < len(toml) {
|
||||
// Skip the backslash and the escaped character
|
||||
end += 2
|
||||
continue
|
||||
}
|
||||
end++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user