Regex101 icon indicating copy to clipboard operation
Regex101 copied to clipboard

Page overload if you paste too much text in the regex box

Open Palloxin opened this issue 1 year ago • 4 comments

Bug Description

Page and browser (and OS) overload if you paste too much text in the regex box

Reproduction steps

largetext.txt Paste the content of this file in the regex box.

Expected Outcome

Probably a character limit in the regex box, for stability reasons Edit: character limit check when text gets pasted

Other details

In the file there are 9.3 milion characters. I somehow pasted by mistake way more than that like 100 and the OS started lagging badly too. I suggest to put a 100k character limit to the regex box or something to prevent the browser to collapse. I am not sure if putting a character check limit would make the match time slower; if so please find another solution.

Browser

Firefox

OS

Windows 10

Palloxin avatar Sep 18 '24 11:09 Palloxin

Maybe a character-limit-check ONLY upon the action of "pasting" text.

Palloxin avatar Sep 18 '24 11:09 Palloxin

When you say regex box do you mean the regular expression input or test string textarea?

working-name avatar Sep 18 '24 17:09 working-name

regular expression box.

The string box can take a lot of text, no problem.

Palloxin avatar Sep 18 '24 22:09 Palloxin

I see. I pasted the text you linked in Brave and it chewed up 8GB of RAM, was responsive for a couple seconds, then the tab crashed: Error code: Out of Memory but the OS is fine. I'm assuming it has to do with the fact that I have plenty of system memory.

working-name avatar Sep 18 '24 22:09 working-name

This is somewhat a limitation of codemirror, and my own doing.

  1. It's all a single line, which makes it very hard to handle for codemirror
  2. The explanation box becomes absolutely massive, which again, requires a lot of resources.

I don't want to add unnecessary artificial limitations to the app, but I agree that this behavior is not ideal. I will experiment a little bit and see what I can do to make this smoother.

firasdib avatar Jan 07 '25 10:01 firasdib

Maybe limit the explaination box only. If the amount of text in the explaination box starts to exceed a number, add a "load more" and warning. Not sure if the majoroty of the overload is given from the regex box tho.

Palloxin avatar Jan 07 '25 11:01 Palloxin

I elected to intercept the paste if it's large and warn the user, see screenshot.

image

firasdib avatar Jan 07 '25 13:01 firasdib