Skip to content
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

Pattern validation with ngModel causes browser freeze on repeated input #12753

Closed
sylvainpolletvillard opened this issue Nov 7, 2016 · 7 comments

Comments

@sylvainpolletvillard
Copy link

I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Having a text input bound with ngModel and a pattern validation, if you hold a letter key while focusing the input to enter a long string such as "aaaaaaaaaaaaa", after ~30 characters the browser freezes and does not respond anymore.

Expected behavior

Angular should prevent browser to freeze when spamming input on a field with complex validation.

Minimal reproduction of the problem with instructions

See http://plnkr.co/edit/ydMZGGQOh62fGwbLh0Yg?p=preview

What is the motivation / use case for changing the behavior?

You don't want browser to freeze or crash because of Angular

Please tell us about your environment:

Windows 7 64 bit

  • Angular version: 2.1.2
  • Browser: Chrome 54
  • Language: all

  • Node (for AoT issues): node --version =

@DzmitryShylovich
Copy link
Contributor

I think it's just inefficient regexp because I cannot reproduce it using different email regexps from the web. For example http://plnkr.co/edit/pFsXDwh5DeHS2551rzAK?p=preview

@sylvainpolletvillard
Copy link
Author

sylvainpolletvillard commented Nov 7, 2016

This regex is not inefficient, it is accurate. The regex you pick validates ---@---.com and other oddities.
Other usual email regexes are even more complicated, such as http://emailregex.com/

@DzmitryShylovich
Copy link
Contributor

Yeah, you're right. Probably we need to debounce input.

@vicb
Copy link
Contributor

vicb commented Nov 7, 2016

This regex is not inefficient

The regexp is inefficient - o(n^2)

http://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016

@vicb vicb closed this as completed Nov 7, 2016
@sylvainpolletvillard
Copy link
Author

Okay fine, it is ineficcient. But don't you think you should still debounce input ? If not a suboptimal regexp, it would be something else next time.

@vicb
Copy link
Contributor

vicb commented Nov 8, 2016

But don't you think you should still debounce input ?

Please submit an other feature request if this has not been reported yet.

(I close this one because the report is not about debouncing)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
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

3 participants