Skip to content

Commit

Permalink
Release 4.3.1 (#176)
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Philippe Zolesio <zolesio@adobe.com>
  • Loading branch information
holblin and Jean-Philippe Zolesio committed Aug 15, 2023
1 parent 964a6ea commit 2b09a25
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
4.3.1 / 2023-03-14
==================

* Fix redos vulnerability with specific crafted css string - CVE-2023-26364

4.3.0 / 2023-03-07
==================

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/css-tools",
"version": "4.3.0",
"version": "4.3.1",
"description": "CSS parser / stringifier",
"source": "src/index.ts",
"main": "./dist/index.cjs",
Expand Down
12 changes: 7 additions & 5 deletions src/parse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import {

// http://www.w3.org/TR/CSS21/grammar.html
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
// New rule => https://www.w3.org/TR/CSS22/syndata.html#comments
// [^] is equivalent to [.\n\r]
const commentre = /\/\*[^]*?(?:\*\/|$)/g;

export const parse = (
css: string,
Expand Down Expand Up @@ -204,8 +206,8 @@ export const parse = (
return;
}

// remove comment in selector; [^] is equivalent to [.\n\r]
const res = trim(m[0]).replace(/\/\*[^]*?\*\//gm, '');
// remove comment in selector;
const res = trim(m[0]).replace(commentre, '');

// Optimisation: If there is no ',' no need to split or post-process (this is less costly)
if (res.indexOf(',') === -1) {
Expand Down Expand Up @@ -654,10 +656,10 @@ export const parse = (
const re = new RegExp(
'^@' +
name +
'\\s*((:?[^;\'"]|"(?:\\\\"|[^"])*?"|\'(?:\\\\\'|[^\'])*?\')+);'
'\\s*((?::?[^;\'"]|"(?:\\\\"|[^"])*?"|\'(?:\\\\\'|[^\'])*?\')+)(?:;|$)'
);

// ^@import\s*([^;"']|("|')(?:\\\2|.)*?\2)+;
// ^@import\s*([^;"']|("|')(?:\\\2|.)*?\2)+(;|$)

return function (): T1 | void {
const pos = position();
Expand Down
1 change: 1 addition & 0 deletions test/cases/at-import-dos/ast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"stylesheet","stylesheet":{"source":"input.css","rules":[{"type":"import","import":":\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':\\'\\'\\'':","position":{"start":{"line":1,"column":1},"end":{"line":1,"column":801},"source":"input.css"}}],"parsingErrors":[]}}
1 change: 1 addition & 0 deletions test/cases/at-import-dos/compressed.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/cases/at-import-dos/input.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/cases/at-import-dos/output.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2b09a25

Please sign in to comment.