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

Inputted domain can be used directly in regex, causing an error #34

Open
m50d opened this issue Apr 3, 2024 · 0 comments
Open

Inputted domain can be used directly in regex, causing an error #34

m50d opened this issue Apr 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@m50d
Copy link

m50d commented Apr 3, 2024

Current Behavior

new RegExp(email.topLevelDomain + '$'),
constructs a regex by string manipulation, which causes an exception if we reach that line with a domain that contains invalid regex syntax.

Expected Behavior

Calling with any input should either suggest an email or fail cleanly (returning undefined), not throw an exception.

Steps to Reproduce the Problem

> const suggestedEmail4 = emailSpellChecker.run({
...   email: 'jorge@bigidaunashtnsuaeonsti.co)',
... })
Uncaught SyntaxError: Invalid regular expression: /co)$/: Unmatched ')'

Environment

  • Version: 1.12.0
  • Platform: Linux
  • Node.js Version: v18.19.0
@m50d m50d added the bug Something isn't working label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant