email-spell-checker icon indicating copy to clipboard operation
email-spell-checker copied to clipboard

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

Open m50d opened this issue 10 months ago • 0 comments

Current Behavior

https://github.com/ZooTools/email-spell-checker/blob/420dc73a72316848c2bd908c6fb95e4aa9aa0855/src/lib/suggest-email.ts#L90 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: '[email protected])',
... })
Uncaught SyntaxError: Invalid regular expression: /co)$/: Unmatched ')'

Environment

  • Version: 1.12.0
  • Platform: Linux
  • Node.js Version: v18.19.0

m50d avatar Apr 03 '24 02:04 m50d