Skip to content

Commit

Permalink
#155 add rules and exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
apparition47 committed Dec 8, 2021
1 parent 6e73cec commit cfcad3a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## [0.5.5] - TBA

- support Mail on macOS 12.1 beta 4 (thanks @ackerthehacker2)
- exception for Fedex spacers (thanks James M.)
- #155 add Telstra rule (thanks @oneofthedamons)

## [0.5.4] - 2021-12-05

Expand Down
10 changes: 8 additions & 2 deletions Source/MTBBlockedMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ - (NSString*)replacedGenericPixelsFrom:(NSString*)html {
template:@"$0"];

NSString* replacement;
if ([match containsString:@"spacer."] || [match containsString:@"attachments.office.net/owa/"]) {
NSString *regexStr = @"spacer|attachments.office.net/owa/|fedex_collective_logo_";
NSRange matchedRange = [match rangeFromPattern:regexStr];
if (matchedRange.location != NSNotFound) {
continue; // no replacement
} else {
replacement = @"";
Expand Down Expand Up @@ -406,7 +408,10 @@ - (NSDictionary*)getTrackerDict {
@"MailTag": @[@"mailtag.io/email-event"],
@"MailTrack": @[@"mailtrack.io/trace", @"mltrk.io/pixel"],
@"Mailzter": @[@"mailzter.in/ltrack"],
@"Mapp": @[@"/tr/p.gif\\?"],
@"Mapp": @[
@"/tr/p.gif\\?",
@"enews.zdnet.com/imagelibrary/"
],
@"Maropost": @[@"/a/\\d{4}/open/\\d{4}/\\d{6,7}/\\w{40}"],
@"Medallia": @[@"survey\\d?.medallia.[A-Za-z]{2,3}/\\?\\w+&invite-opened=yes"],
@"Meta": @[
Expand Down Expand Up @@ -564,6 +569,7 @@ - (NSDictionary*)getTrackerDict {
@"Superhuman": @[@"r.superhuman.com"],
@"TataDocomoBusiness": @[@"tatadocomobusiness.com/rts/"],
@"Techgig": @[@"tj_mailer_opened_count_all.php"],
@"Telstra": @[@"tapi.telstra.com/presentation/v1/notification-mngmt/delivery-status-tracker"],
@"The Atlantic": @[
@"links.e.theatlantic.com/open/log/",
@"data-cdn.theatlantic.com/email.gif"
Expand Down
12 changes: 12 additions & 0 deletions Unit Tests/MTBBlockedMessageTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ - (void)testSpacers {
XCTAssertEqualObjects(msg3.sanitizedHtml, email3);
XCTAssertEqualObjects(msg3.detectedTracker, nil);
XCTAssertEqual(msg3.certainty, BLOCKING_RESULT_CERTAINTY_LOW_NO_MATCHES);

NSString *email4 = @"<img style=\"display:inline-block; color: #4D148C;\" alt=\"FedEx\" height=\"157\" width=\"44\" border=\"0\" src=\"http://www.fedex.com/ENS/images/fedex_collective_logo_desktop.png\">";
MTBBlockedMessage *msg4 = [[MTBBlockedMessage alloc] initWithHtml:email4];
XCTAssertEqualObjects(msg4.sanitizedHtml, email4);
XCTAssertEqualObjects(msg4.detectedTracker, nil);
XCTAssertEqual(msg4.certainty, BLOCKING_RESULT_CERTAINTY_LOW_NO_MATCHES);

NSString *email5 = @"<img alt=\"FedEx\" border=\"0\" class=\"showonmobilelogo\" style=\"display:none;width:0px;max-height:0px;overflow:hidden;\" height=\"1\" width=\"1\" src=\"http://www.fedex.com/ENS/images/fedex_collective_logo_mobile.png\">";
MTBBlockedMessage *msg5 = [[MTBBlockedMessage alloc] initWithHtml:email5];
XCTAssertEqualObjects(msg5.sanitizedHtml, email5);
XCTAssertEqualObjects(msg5.detectedTracker, nil);
XCTAssertEqual(msg5.certainty, BLOCKING_RESULT_CERTAINTY_LOW_NO_MATCHES);
}

#pragma mark - Helpers
Expand Down

0 comments on commit cfcad3a

Please sign in to comment.