-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #26: Now properly escaping within the regular expressions we us…
…e for stripping email addresses.
- Loading branch information
Eyal Rozenberg
committed
Nov 26, 2020
1 parent
0f62486
commit 52abbcd
Showing
1 changed file
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,12 +469,12 @@ RemoveDupes.MessengerOverlay = { | |
// disallowed email address beginning with an apostrophy (') to | ||
// better handle single-quoted addresses such as | ||
// '[email protected]' | ||
"(?:\b|^)[a-z0-9!#$%&*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + | ||
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\b|$)","gi"); | ||
"(?:\\b|^)[a-z0-9!#$%&*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + | ||
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\b|$)","gi"); | ||
const gSingleQuotedEmailRegExp = RegExp( | ||
"(?:\b|^)'[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + | ||
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'","gi"); | ||
const gEncodedWordRegExp = RegExp("=\?.*\?=","g"); | ||
"(?:\\b|^)'[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + | ||
"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?'","gi"); | ||
const gEncodedWordRegExp = RegExp("=\\?.*\\?=","g"); | ||
#ifdef DEBUG_stripAndSortAddresses | ||
console.log('stripAndSortAddresses(' + headerString + ')'); | ||
#endif | ||
|
@@ -485,6 +485,9 @@ RemoveDupes.MessengerOverlay = { | |
if (gEncodedWordRegExp.test(headerString)) | ||
return headerString; | ||
var matches; | ||
#ifdef DEBUG_stripAndSortAddresses | ||
console.log('headerString.match(gEmailRegExp) with gEmailRegExp = ' + gEmailRegExp); | ||
#endif | ||
matches = headerString.match(gEmailRegExp); | ||
if (!matches) { | ||
// let's try looking for addresses within single quotes, | ||
|