Skip to content

Commit f0f8210

Browse files
authored
Batch: Fix escaped double quote (#2485)
1 parent 649e51e commit f0f8210

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

components/prism-batch.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'punctuation': /:/
88
}
99
};
10-
var string = /"[^"]*"/;
10+
var string = /"(?:[\\"]"|[^"])*"(?!")/;
1111
var number = /(?:\b|-)\d+\b/;
1212

1313
Prism.languages.batch = {
@@ -76,7 +76,7 @@
7676
},
7777
{
7878
// Other commands
79-
pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
79+
pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:"(?:[\\"]"|[^"])*"(?!")|[^"^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
8080
lookbehind: true,
8181
inside: {
8282
'keyword': /^\w+\b/i,
@@ -96,4 +96,4 @@
9696
'operator': /[&@]/,
9797
'punctuation': /[()']/
9898
};
99-
}(Prism));
99+
}(Prism));

components/prism-batch.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmd ""
2+
cmd "f\"oo"
3+
cmd "f\\"oo"
4+
cmd "print(""hello"")"
5+
6+
----------------------------------------------------
7+
8+
[
9+
["command", [
10+
["keyword", "cmd"],
11+
["string", "\"\""]
12+
]],
13+
["command", [
14+
["keyword", "cmd"],
15+
["string", "\"f\\\"oo\""]
16+
]],
17+
["command", [
18+
["keyword", "cmd"],
19+
["string", "\"f\\\\\"oo\""]
20+
]],
21+
["command", [
22+
["keyword", "cmd"],
23+
["string", "\"print(\"\"hello\"\")\""]
24+
]]
25+
]
26+
27+
----------------------------------------------------
28+
29+
Checks for strings.

0 commit comments

Comments
 (0)