Skip to content

regex is evil regex #308

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

Closed
amalamalpm opened this issue Dec 14, 2015 · 4 comments
Closed

regex is evil regex #308

amalamalpm opened this issue Dec 14, 2015 · 4 comments
Labels

Comments

@amalamalpm
Copy link

It is a code segment in prototype.js

findChildElements: function(element, expressions) {
var exprs = expressions.join(','), expressions = [];
exprs.scan(/(([\w#:.~>+()\s-]+|*|[.?])+)\s(,|$)/, function(m) {
......

If we given value of exprs as

 exprs="#microsoft-windowserw-appmodel-runtime/admin";

and call this function will make the browser hang. especially Google chrome.

Simply we can say following line will hang the browser.

"#microsoft-windowserw-appmodel-runtime/admin".match(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/);

So please try to modify this evil regex. Thank you

@amalamalpm
Copy link
Author

An element name or id can contain any symbols, including (\ / < >)

@savetheclocktower
Copy link
Collaborator

Yeah, a slash in an ID used to be forbidden, but HTML5 has much looser rules about this. I'll take a look.

@savetheclocktower
Copy link
Collaborator

Actually, it looks like the only place this regex is used is in our legacy selector engine, which we haven't updated in years. What version of Prototype are you on? Newer versions should be using Sizzle.

Closing for now.

@amalamalpm
Copy link
Author

Thanks for your update

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

No branches or pull requests

2 participants