Skip to content

Commit 41f85fa

Browse files
author
Jean-Philippe Zolesio
committed
Release 4.3.2
1 parent 49bc539 commit 41f85fa

File tree

8 files changed

+551
-495
lines changed

8 files changed

+551
-495
lines changed

History.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
4.3.2 / 2023-11-28
2+
==================
3+
4+
* Fix redos vulnerability with specific crafted css string - CVE-2023-48631
5+
* Fix Problem parsing with :is() and nested :nth-child() #211
6+
7+
18
4.3.1 / 2023-03-14
29
==================
310

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobe/css-tools",
3-
"version": "4.3.1",
3+
"version": "4.3.2",
44
"description": "CSS parser / stringifier",
55
"source": "src/index.ts",
66
"main": "./dist/index.cjs",
@@ -16,8 +16,8 @@
1616
"Readme.md"
1717
],
1818
"devDependencies": {
19-
"@parcel/packager-ts": "2.9.3",
20-
"@parcel/transformer-typescript-types": "2.9.3",
19+
"@parcel/packager-ts": "2.10.3",
20+
"@parcel/transformer-typescript-types": "2.10.3",
2121
"@types/benchmark": "^2.1.1",
2222
"@types/bytes": "^3.1.1",
2323
"@types/jest": "^29.5.3",
@@ -26,7 +26,7 @@
2626
"bytes": "^3.1.0",
2727
"gts": "^5.0.0",
2828
"jest": "^29.6.2",
29-
"parcel": "^2.9.3",
29+
"parcel": "^2.10.3",
3030
"ts-jest": "^29.1.1",
3131
"typescript": "^5.0.2"
3232
},

src/parse/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,17 @@ export const parse = (
227227
*
228228
* Regex logic:
229229
* ("|')(?:\\\1|.)*?\1 => Handle the " and '
230-
* \(.*?\) => Handle the ()
230+
* \((?:[^()]*?|(\(.*?\))*)*\) => Handle the () and the (())
231231
*
232232
* Optimization 1:
233233
* No greedy capture (see docs about the difference between .* and .*?)
234234
*
235235
* Optimization 2:
236236
* ("|')(?:\\\1|.)*?\1 this use reference to capture group, it work faster.
237237
*/
238-
.replace(/("|')(?:\\\1|.)*?\1|\(.*?\)/g, m => m.replace(/,/g, '\u200C'))
238+
.replace(/("|')(?:\\\1|.)*?\1|\((?:[^()]*?|(\([^)]*?\))*)*\)/g, m =>
239+
m.replace(/,/g, '\u200C')
240+
)
239241
// Split the selector by ','
240242
.split(',')
241243
// Replace back \u200C by ','
@@ -522,7 +524,7 @@ export const parse = (
522524
*/
523525
function atcustommedia(): CssCustomMediaAST | void {
524526
const pos = position();
525-
const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
527+
const m = match(/^@custom-media\s+(--\S+)\s*([^{;\s][^{;]*);/);
526528
if (!m) {
527529
return;
528530
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"type": "stylesheet",
3+
"stylesheet": {
4+
"rules": [
5+
{
6+
"type": "rule",
7+
"selectors": [
8+
".klass:is(:nth-child(1), :nth-child(2))"
9+
],
10+
"declarations": [
11+
{
12+
"type": "declaration",
13+
"property": "margin",
14+
"value": "0 !important",
15+
"position": {
16+
"start": {
17+
"line": 1,
18+
"column": 42
19+
},
20+
"end": {
21+
"line": 1,
22+
"column": 62
23+
},
24+
"source": "input.css"
25+
}
26+
}
27+
],
28+
"position": {
29+
"start": {
30+
"line": 1,
31+
"column": 1
32+
},
33+
"end": {
34+
"line": 1,
35+
"column": 63
36+
},
37+
"source": "input.css"
38+
}
39+
}
40+
]
41+
}
42+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.klass:is(:nth-child(1), :nth-child(2)){margin:0 !important;}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.klass:is(:nth-child(1), :nth-child(2)) {margin: 0 !important}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.klass:is(:nth-child(1), :nth-child(2)) {
2+
margin: 0 !important;
3+
}

0 commit comments

Comments
 (0)