From 236c2669ba3bd29af5c396900c7a28e8e11bfc78 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Wed, 27 Jun 2018 12:38:05 -0600 Subject: [PATCH 1/8] :bug: Forbid comments from ending in triple dash --- grammars/xml.cson | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grammars/xml.cson b/grammars/xml.cson index d484a36..74f6af1 100644 --- a/grammars/xml.cson +++ b/grammars/xml.cson @@ -403,3 +403,9 @@ 'name': 'punctuation.definition.comment.xml' 'end': '--%?>' 'name': 'comment.block.xml' + 'patterns': [ + { + 'match': '-{3,}>' + 'name': 'invalid.illegal.bad-comments-or-CDATA.xml' + } + ] From 346967cd661d796999fa6c2a31fd453bf3e04444 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Wed, 27 Jun 2018 22:45:18 -0600 Subject: [PATCH 2/8] Update xml-spec.coffee --- spec/xml-spec.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/xml-spec.coffee b/spec/xml-spec.coffee index c7055fc..c8ff98e 100644 --- a/spec/xml-spec.coffee +++ b/spec/xml-spec.coffee @@ -24,6 +24,13 @@ describe "XML grammar", -> expect(lines[1][1]).toEqual value: '' + + expect(tokens[0]).toEqual value: '', scopes: ['text.xml', 'comment.block.xml', 'invalid.illegal.bad-comments-or-CDATA.xml'] it "tokenizes empty element meta.tag.no-content.xml", -> {tokens} = grammar.tokenizeLine('') From 0c67c4052f19a8d0a68239c1f2b461e07265df1a Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Wed, 27 Jun 2018 22:50:01 -0600 Subject: [PATCH 3/8] Update xml-spec.coffee --- spec/xml-spec.coffee | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/xml-spec.coffee b/spec/xml-spec.coffee index c8ff98e..213178d 100644 --- a/spec/xml-spec.coffee +++ b/spec/xml-spec.coffee @@ -25,12 +25,11 @@ describe "XML grammar", -> expect(lines[2][1]).toEqual value: '' - - expect(tokens[0]).toEqual value: '', scopes: ['text.xml', 'comment.block.xml', 'invalid.illegal.bad-comments-or-CDATA.xml'] + it 'tokenizes comments with three dashes as invalid', -> + {tokens} = grammar.tokenizeLine('') + expect(tokens[0]).toEqual value: '', scopes: ['text.xml', 'comment.block.xml', 'invalid.illegal.bad-comments-or-CDATA.xml'] it "tokenizes empty element meta.tag.no-content.xml", -> {tokens} = grammar.tokenizeLine('') From d633e8b547ec0a00e248324507bc369cce13b067 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Thu, 28 Jun 2018 14:30:24 -0600 Subject: [PATCH 4/8] Invalidate comments with more than two dashes --- grammars/xml.cson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grammars/xml.cson b/grammars/xml.cson index 74f6af1..2c02948 100644 --- a/grammars/xml.cson +++ b/grammars/xml.cson @@ -405,7 +405,7 @@ 'name': 'comment.block.xml' 'patterns': [ { - 'match': '-{3,}>' + 'match': '(?)' 'name': 'invalid.illegal.bad-comments-or-CDATA.xml' } ] From d535ac156206081b33618cd801a18a9958ea579f Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Thu, 28 Jun 2018 14:46:12 -0600 Subject: [PATCH 5/8] Invalidate comments with more than two dashes --- spec/xml-spec.coffee | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spec/xml-spec.coffee b/spec/xml-spec.coffee index 213178d..b8945db 100644 --- a/spec/xml-spec.coffee +++ b/spec/xml-spec.coffee @@ -24,12 +24,20 @@ describe "XML grammar", -> expect(lines[1][1]).toEqual value: '') expect(tokens[0]).toEqual value: '', scopes: ['text.xml', 'comment.block.xml', 'invalid.illegal.bad-comments-or-CDATA.xml'] + expect(tokens[2]).toEqual value: '--', scopes: ['text.xml', 'comment.block.xml', 'invalid.illegal.bad-comments-or-CDATA.xml'] + + it 'tokenizes comments with two dashes not followed by ">"', -> + {tokens} = grammar.tokenizeLine('') + expect(tokens[0]).toEqual value: '', scopes: ['text.xml', 'comment.block.xml', 'punctuation.definition.comment.xml'] it "tokenizes empty element meta.tag.no-content.xml", -> {tokens} = grammar.tokenizeLine('') @@ -47,7 +55,7 @@ describe "XML grammar", -> """ expect(linesWithIndent[1][1]).toEqual value: 'attrName', scopes: ['text.xml', 'meta.tag.xml', 'entity.other.attribute-name.localname.xml'] - + linesWithoutIndent = grammar.tokenizeLines """ From 0a04e02d4b179688526938f19ae3de666fe07770 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Fri, 29 Jun 2018 10:03:32 -0600 Subject: [PATCH 6/8] Split JSP and XML comments Also, only highlight first occurrence of `--` --- grammars/xml.cson | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/grammars/xml.cson b/grammars/xml.cson index 2c02948..30f45b9 100644 --- a/grammars/xml.cson +++ b/grammars/xml.cson @@ -397,15 +397,29 @@ } ] 'comments': - 'begin': '<[!%]--' - 'captures': - '0': - 'name': 'punctuation.definition.comment.xml' - 'end': '--%?>' - 'name': 'comment.block.xml' 'patterns': [ { - 'match': '(?)' - 'name': 'invalid.illegal.bad-comments-or-CDATA.xml' + 'begin': '<%--' + 'captures': + '0': + 'name': 'punctuation.definition.comment.xml' + 'end': '--%>' + 'name': 'comment.block.xml' + } + { + 'begin': '' + 'name': 'comment.block.xml' + 'patterns': [ + { + 'begin': '--(?!>)' + 'captures': + '0': + 'name': 'invalid.illegal.bad-comments-or-CDATA.xml' + } + ] } ] From 9be71761996315a5e9913f8e88920db2c1668913 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Fri, 29 Jun 2018 10:10:19 -0600 Subject: [PATCH 7/8] Update xml-spec.coffee --- spec/xml-spec.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/xml-spec.coffee b/spec/xml-spec.coffee index b8945db..e2af4e7 100644 --- a/spec/xml-spec.coffee +++ b/spec/xml-spec.coffee @@ -25,19 +25,18 @@ describe "XML grammar", -> expect(lines[2][1]).toEqual value: '') expect(tokens[0]).toEqual value: '') expect(tokens[0]).toEqual value: '', scopes: ['text.xml', 'comment.block.xml', 'punctuation.definition.comment.xml'] + expect(tokens[3]).toEqual value: ' comment -->', scopes: ['text.xml', 'comment.block.xml'] it "tokenizes empty element meta.tag.no-content.xml", -> {tokens} = grammar.tokenizeLine('') From 71718a53838e99321190466ec5a88e7152cf8912 Mon Sep 17 00:00:00 2001 From: Steven Tang Date: Fri, 29 Jun 2018 10:18:53 -0600 Subject: [PATCH 8/8] Update xml-spec.coffee --- spec/xml-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/xml-spec.coffee b/spec/xml-spec.coffee index e2af4e7..6320738 100644 --- a/spec/xml-spec.coffee +++ b/spec/xml-spec.coffee @@ -25,7 +25,7 @@ describe "XML grammar", -> expect(lines[2][1]).toEqual value: '') expect(tokens[0]).toEqual value: '