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

Issue withSignature Regex #30

Open
garyhalb opened this issue Nov 29, 2017 · 2 comments
Open

Issue withSignature Regex #30

garyhalb opened this issue Nov 29, 2017 · 2 comments
Labels

Comments

@garyhalb
Copy link

There appears to be an issue with the original regex defined for matching signatures:
(--|__|-\w)|(^Sent from my (\w+\s*){1,3})

The above correctly matches the phrase: 'Sent from my iPhone' etc.

But the first group also matches any line containing '--', '__' or '-'. So you get matches for any line containing a hyphenated word for instance:
'This is an auto-reply test to see if I receive an automated message'

I've tested this using the online tool at https://regex101.com/ and also using the built-in .Net regular expression matcher.

The fix appears to be to ensure the first group only looks for matches that start with the defined characters:
(^--|^__|^-\w)|(^Sent from my (\w+\s*){1,3})

@roycehaynes
Copy link
Contributor

@garyhalb - Interesting catch. Let me see if I can come up with a test case that addresses the error mentioned. Thanks for documenting!

@roycehaynes roycehaynes added the bug label Jan 9, 2018
@rockwotj
Copy link

BTW, this is what github's library does does: (--\s*$|__\s*$|\w-$)

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

3 participants