Skip to content

Commit 353f810

Browse files
committed
Scope invalid escape sequences in double quoted yaml strings
Resolves #415
1 parent 421c865 commit 353f810

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed

Package/Sublime Text Syntax Definition/Sublime Text Syntax Definition.sublime-syntax

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,10 @@ contexts:
602602
scope: punctuation.definition.string.begin.yaml
603603
push:
604604
- meta_scope: comment.other.quoted.double.sublime-syntax
605-
- match: \\.
606-
scope: constant.character.escape.yaml
607605
- match: '"'
608606
scope: punctuation.definition.string.end.yaml
609607
pop: true
608+
- include: yaml-double-quoted-escapes
610609

611610
- match: "'"
612611
scope: punctuation.definition.string.begin.yaml
@@ -660,12 +659,11 @@ contexts:
660659
push:
661660
- meta_scope: string.quoted.double.yaml
662661
- meta_content_scope: source.regexp.oniguruma
663-
- include: regexp_variable
664-
- match: \\.
665-
scope: constant.character.escape.yaml
666662
- match: '"'
667663
scope: punctuation.definition.string.end.yaml
668664
pop: 2
665+
- include: yaml-double-quoted-escapes
666+
- include: regexp_variable
669667

670668
- match: "'"
671669
scope: punctuation.definition.string.begin.yaml
@@ -794,3 +792,15 @@ contexts:
794792

795793
yaml-tags-anchors:
796794
- include: YAML.sublime-syntax#property
795+
796+
yaml-double-quoted-escapes:
797+
- match: \\[ 0_abefLnNPprtv/\\"]
798+
scope: constant.character.escape.yaml
799+
- match: \\x\h{2}
800+
scope: constant.character.escape.unicode.8bit.yaml
801+
- match: \\u\h{4}
802+
scope: constant.character.escape.unicode.16bit.yaml
803+
- match: \\U\h{8}
804+
scope: constant.character.escape.unicode.32bit.yaml
805+
- match: \\.
806+
scope: invalid.illegal.escape.yaml

Package/Sublime Text Syntax Definition/syntax_test_sublime-syntax.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,13 @@ contexts:
252252
- comment: "this is a \"comment"
253253
# ^^^^^^^^^^^^^^^^^^^^^ comment.other.quoted.double.sublime-syntax
254254
# ^ punctuation.definition.string.begin.yaml
255+
# ^^ constant.character.escape.yaml
255256
# ^ punctuation.definition.string.end.yaml
256257

257258
comment: 'this is a ''comment'
258259
# ^^^^^^^^^^^^^^^^^^^^^ comment.other.quoted.single.sublime-syntax
259260
# ^ punctuation.definition.string.begin.yaml
261+
# ^^ constant.character.escape.yaml
260262
# ^ punctuation.definition.string.end.yaml
261263

262264
- comment: |-
@@ -288,6 +290,61 @@ contexts:
288290
(?x) # extended group with comments
289291
# ^^^^ source.regexp.oniguruma meta.group.extended.regexp
290292
# ^ source.regexp.oniguruma comment.line.number-sign.regexp punctuation.definition.comment.regexp
293+
294+
- match: "(?=\0)"
295+
# ^^ constant.character.escape.yaml
296+
- match: "(?=\a)"
297+
# ^^ constant.character.escape.yaml
298+
- match: "(?=\b)"
299+
# ^^ constant.character.escape.yaml
300+
- match: "(?=\t)"
301+
# ^^ constant.character.escape.yaml
302+
- match: "(?=\n)"
303+
# ^^ constant.character.escape.yaml
304+
- match: "(?=\v)"
305+
# ^^ constant.character.escape.yaml
306+
- match: "(?=\f)"
307+
# ^^ constant.character.escape.yaml
308+
- match: "(?=\r)"
309+
# ^^ constant.character.escape.yaml
310+
- match: "(?=\e)"
311+
# ^^ constant.character.escape.yaml
312+
- match: "(?=\ )"
313+
# ^^ constant.character.escape.yaml
314+
- match: "(?=\")"
315+
# ^^ constant.character.escape.yaml
316+
- match: "(?=\/)"
317+
# ^^ constant.character.escape.yaml
318+
- match: "(?=\\)"
319+
# ^^ constant.character.escape.yaml
320+
- match: "(?=\N)"
321+
# ^^ constant.character.escape.yaml
322+
- match: "(?=\_)"
323+
# ^^ constant.character.escape.yaml
324+
- match: "(?=\L)"
325+
# ^^ constant.character.escape.yaml
326+
- match: "(?=\P)"
327+
# ^^ constant.character.escape.yaml
328+
- match: "(?=\ )"
329+
# ^^ constant.character.escape.yaml
330+
- match: "(?=\ )"
331+
# ^^ constant.character.escape.yaml
332+
- match: "(?=\ )"
333+
# ^^ constant.character.escape.yaml
334+
- match: "(?=\')"
335+
# ^^ invalid.illegal.escape.yaml
336+
- match: "(?=\m)"
337+
# ^^ invalid.illegal.escape.yaml
338+
- match: "(?=\x1234)"
339+
# ^^^^ constant.character.escape.unicode.8bit.yaml
340+
# ^^ - constant.character.escape
341+
- match: "(?=\u123fd)"
342+
# ^^^^^^ constant.character.escape.unicode.16bit.yaml
343+
# ^ - constant.character.escape
344+
- match: "(?=\U123fda3f2)"
345+
# ^^^^^^^^^^ constant.character.escape.unicode.32bit.yaml
346+
# ^ - constant.character.escape
347+
291348
- scope: abc
292349
# ^^^^^ string.unquoted.plain.out.yaml storage.type.scope-name.sublime-syntax
293350
- meta_scope: abc

0 commit comments

Comments
 (0)