New issue
Advanced search Search tips

Issue 852717 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue v8:287
Owner: ----
Closed: Jun 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Long RegEx that does not match with a long string crashes website

Reported by skortenb...@gmail.com, Jun 14 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36

Steps to reproduce the problem:
Copy the following commands in the browser console and execute them:
1.
var text = "https://test.example.com/examplefolder/index.html?param1=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsInZlciI6MX0.eyJpc3MiOiJjb21wb25lbnRMaWNlbmNlU2VydmVyIiwibGljIjoiMGUxNzZmZDgtZjdjZS00OWQwLTg4NDEtMGExMzE3ODQ3YjI4Iiwic3ViIjoiNjQ5NDItMDYwMzQiLCJ0aWQiOjQxODExNiwiY2lkIjoxfQ.fq8ikVqrnpd_s86lz8H4c_GULO2EHdbT8bq4NRAy5fGyxtiSSZRHPL900FvKbbOOtuvdtplvNqG8tEmZH2WUwA&param2=0&param3=64942-06034&param4=1&param5=webshadow&param6=418116&param7=37913C&param8=0&param9=1&_=15289629061724455544455&INVALID_STRING_PART="
2. 
var regEx = /^(https?:)?(\/\/)?((([\däöüa-z-]+\.)+)([a-z]{2,12})|((([0-9]{1,3}\.){3})[0-9]{1,3})|(localhost))(:[0-9]{2,5})?(\/?)(\/[\wäöü\.-]+)*((#.*)|((\/?\?((##.+##)|([\wäöü#%\.-]+(=[\wäöü,#%\.\/-]+)?))+)(\&((##.+##)|([\wäöü,#%\.-]+(=[\wäöü,#%\.-]+)?)))*?)?)\/?$/gi
3. regEx.test(text)

What is the expected behavior?
regEx.test(text) should return false.

What went wrong?
Website freezes and in some cases the complete browser crashes.

Did this work before? N/A 

Chrome version: 67.0.3396.87  Channel: stable
OS Version: 10.0
Flash Version: 

Works as intended when the regex matches, with shorter strings the site does not crash but return takes a long time.
 

Comment 1 by woxxom@gmail.com, Jun 14 2018

"Catastrophic Backtracking" as per https://regex101.com/r/1a3A6g/1
It hangs Firefox too so you may want to rework your expression.
I know that the performance of this regex is not great, but it worked fine in  older Chrome versions. I updated today after I recieved reports from colleagues that their browser freezes. You are right that other browsers hang too, but that does not mean Chrome has to do the same.

Comment 3 by woxxom@gmail.com, Jun 14 2018

The test case you've posted above doesn't work in older versions of Chrome.
Tested in Chrome 31, 41, 51, 61, 66, 67, 69.
Didn't finish even after a minute.
Labels: Needs-Triage-M67

Comment 5 by rtoy@chromium.org, Jun 14 2018

Components: -Blink Blink>JavaScript>Regexp
Status: Untriaged (was: Unconfirmed)
The repro case locks up my tab as well.
Mergedinto: v8:287
Status: Duplicate (was: Untriaged)

Sign in to add a comment