Skip to content

Commit 276a4b2

Browse files
committed
fix(parse): Disallow quotes around unpacked pseudos
1 parent f07d582 commit 276a4b2

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/parse.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const broken = [
3232
"[id=012345678901234567890123456789",
3333
"input[name=foo.baz]",
3434
"input[name=foo[baz]]",
35+
':has("p")',
3536
];
3637

3738
describe("Broken selectors", () => {

src/parse.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,17 @@ function parseSelector(
311311

312312
if (selector.startsWith("(")) {
313313
if (unpackPseudos.has(name)) {
314-
const quot = selector.charAt(1);
315-
const quoted = quotes.has(quot);
314+
if (quotes.has(selector.charAt(1))) {
315+
throw new Error(
316+
`Pseudo-selector ${name} cannot be quoted`
317+
);
318+
}
316319

317-
selector = selector.substr(quoted ? 2 : 1);
320+
selector = selector.substr(1);
318321

319322
data = [];
320323
selector = parseSelector(data, selector, options);
321324

322-
if (quoted) {
323-
if (!selector.startsWith(quot)) {
324-
throw new Error(`Unmatched quotes in :${name}`);
325-
} else {
326-
selector = selector.substr(1);
327-
}
328-
}
329-
330325
if (!selector.startsWith(")")) {
331326
throw new Error(
332327
`Missing closing parenthesis in :${name} (${selector})`

0 commit comments

Comments
 (0)