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

LinkExtension - Incorrect detection of email address #1976

Open
ctaschereau opened this issue Jan 5, 2023 · 1 comment
Open

LinkExtension - Incorrect detection of email address #1976

ctaschereau opened this issue Jan 5, 2023 · 1 comment
Labels
type: bug 🪲 Something isn't working

Comments

@ctaschereau
Copy link

ctaschereau commented Jan 5, 2023

Summary

When using the linkExtension, if I use a text in the following form :
From : John Smith <john.smith@test.com>

The "<" symbol is considered to be part of the email address

Steps to reproduce

Paste this into a remirror rich text using the link extension :
From : John Smith <john.smith@test.com>

Expected results

The detected email address should be "john.smith@test.com"

Actual results

The detected email address is "<john.smith@test.com" (which is invalid)

Possible Solution

I modified the autoLinkRegex to use this instead :

  /(?:(?:(?:https?|ftp):)?\/\/)?(?:[\w.\-+]+(?::[\w.\-+]*)?@)?(?:(?:[\da-z\u00A1-\uFFFF][\w\u00A1-\uFFFF-]{0,62})?[\da-z\u00A1-\uFFFF]\.)*(?:(?:\d(?!\.)|[a-z\u00A1-\uFFFF])(?:[\da-z\u00A1-\uFFFF][\w\u00A1-\uFFFF-]{0,62})?[\da-z\u00A1-\uFFFF]\.)+[a-z\u00A1-\uFFFF]{2,}(?::\d{2,5})?(?:[#/?]\S*)?/gi,

The only changes being using [\w.\-+] instead of \S (twice) before the "@"

@ctaschereau ctaschereau added the type: bug 🪲 Something isn't working label Jan 5, 2023
@ctaschereau
Copy link
Author

It may be possible to have a wider range of allowed characters than [\w.-+], but this worked for all of my use cases for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant