Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 4.3.1 #176

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading