Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Truncate Regex Causes Infinite Loop #24

Open
jbasdf opened this issue Mar 16, 2017 · 7 comments
Open

Truncate Regex Causes Infinite Loop #24

jbasdf opened this issue Mar 16, 2017 · 7 comments

Comments

@jbasdf
Copy link

jbasdf commented Mar 16, 2017

This commit adds no value attributes to the truncation process but also introduces an infinite loop. Running this regex: KEY_VALUE_REGEX = '([\w|-]+\s*(=\s*"[^"]")?\s)*' on an iframe with attributes with and without values will result in the process freezing. For example, this bit of code will result in the process locking:
<iframe width="560" height="315" src="//www.youtube.com/embed/eFGolAT2l6c" frameborder="0" allowfullscreen></iframe>

The specific line that freezes is 205:
selfClose = SELF_CLOSE_REGEX.exec(result);

This error can be reproduced by executing that line of code, having set the pertinent values, on the command line. I've also written a test to demonstrate the problem on this branch:

master...jbasdf:locking_bug

@mdevine82
Copy link

Wanted to bump this because its still an issue and another component I want to use relies on this library.

@kylefarris
Copy link

I'm actually experiencing this issue as well. A block of HTML I'm trying to truncate contains a Vimeo video embed and has attributes with no value so it's causing the process to lock up. :-(

@ex1st
Copy link

ex1st commented Feb 28, 2019

Hello @huang47, do you plan any updates? Thank you.

@thephucit
Copy link

Same issue, there is any solution?

@oferRounds
Copy link

same.. any solution?

@mhluska
Copy link

mhluska commented Apr 9, 2020

Same issue. Seems like this was reverted in 2017 though? be300c7

@huang47 @pakmanlh can you please publish a 1.2.3 version? 🙏

@nop1984
Copy link

nop1984 commented Sep 7, 2024

And seems like it still does, hangs on HTML with 3 P and one nested IMG

P.S. Surprising ppl still trying to make gold from plumbum parse HTML with regex

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants