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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy