Skip to content

Commit

Permalink
Fixes #26: Now properly escaping within the regular expressions we us…
Browse files Browse the repository at this point in the history
…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.
13 changes: 8 additions & 5 deletions src/chrome/content/removedupes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 52abbcd

Please sign in to comment.