File tree 3 files changed +15
-2
lines changed 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
6
6
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
7
7
8
+ ## [ 12.3.2] - 2022-01-08
9
+ ### Security
10
+ - Fix possible ReDOS in newline rule. Thanks to @MakeNowJust .
11
+
8
12
9
13
## [ 12.3.1] - 2022-01-07
10
14
### Fixed
@@ -588,6 +592,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
588
592
- Renamed presets folder (configs -> presets).
589
593
590
594
595
+ [ 12.3.2 ] : https://github.com/markdown-it/markdown-it/compare/12.3.1...12.3.2
591
596
[ 12.3.1 ] : https://github.com/markdown-it/markdown-it/compare/12.3.0...12.3.1
592
597
[ 12.3.0 ] : https://github.com/markdown-it/markdown-it/compare/12.2.0...12.3.0
593
598
[ 12.2.0 ] : https://github.com/markdown-it/markdown-it/compare/12.1.0...12.2.0
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var isSpace = require('../common/utils').isSpace;
6
6
7
7
8
8
module . exports = function newline ( state , silent ) {
9
- var pmax , max , pos = state . pos ;
9
+ var pmax , max , ws , pos = state . pos ;
10
10
11
11
if ( state . src . charCodeAt ( pos ) !== 0x0A /* \n */ ) { return false ; }
12
12
@@ -20,7 +20,11 @@ module.exports = function newline(state, silent) {
20
20
if ( ! silent ) {
21
21
if ( pmax >= 0 && state . pending . charCodeAt ( pmax ) === 0x20 ) {
22
22
if ( pmax >= 1 && state . pending . charCodeAt ( pmax - 1 ) === 0x20 ) {
23
- state . pending = state . pending . replace ( / + $ / , '' ) ;
23
+ // Find whitespaces tail of pending chars.
24
+ ws = pmax - 1 ;
25
+ while ( ws >= 1 && state . pending . charCodeAt ( ws - 1 ) === 0x20 ) ws -- ;
26
+
27
+ state . pending = state . pending . slice ( 0 , ws ) ;
24
28
state . push ( 'hardbreak' , 'br' , 0 ) ;
25
29
} else {
26
30
state . pending = state . pending . slice ( 0 , - 1 ) ;
Original file line number Diff line number Diff line change @@ -138,5 +138,9 @@ describe('Pathological sequences speed', () => {
138
138
it ( 'autolinks <<<<...<<> pattern' , async ( ) => {
139
139
await test_pattern ( '<' . repeat ( 400000 ) + '>' ) ;
140
140
} ) ;
141
+
142
+ it ( 'hardbreak whitespaces pattern' , async ( ) => {
143
+ await test_pattern ( 'x' + ' ' . repeat ( 150000 ) + 'x \nx' ) ;
144
+ } ) ;
141
145
} ) ;
142
146
} ) ;
You can’t perform that action at this time.
0 commit comments