Skip to content

Commit

Permalink
Fix notifications not forwarded for e-mails with quotation marks in t…
Browse files Browse the repository at this point in the history
…itle
  • Loading branch information
joelekstrom committed Jan 30, 2022
1 parent 6f7b2c7 commit d561d9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Fastmate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 5RNJHF933P;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Fastmate/Info.plist;
Expand All @@ -375,7 +375,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 5RNJHF933P;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Fastmate/Info.plist;
Expand Down
2 changes: 1 addition & 1 deletion Fastmate/Fastmate.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Notification = function(title, options) {
++notificationID;
var n = new originalNotification(title, options);
Object.defineProperty(n, "onclick", { set: function(value) { Fastmate.notificationClickHandlers[notificationID.toString()] = value; }});
window.webkit.messageHandlers.Fastmate.postMessage('{"title": "' + title + '", "options": ' + JSON.stringify(options) + ', "notificationID": ' + notificationID + '}');
window.webkit.messageHandlers.Fastmate.postMessage('{"title": ' + JSON.stringify(title) + ', "options": ' + JSON.stringify(options) + ', "notificationID": ' + notificationID + '}');
return n;
}

Expand Down
6 changes: 5 additions & 1 deletion Fastmate/WebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ - (void)copyURLToPasteboard:(NSURL *)URL {
}

- (void)postNotificationForMessage:(WKScriptMessage *)message {
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[message.body dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
NSError *error = nil;
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[message.body dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];
if (error) {
NSLog(@"Failed to decode notification with body: %@. Error: %@", message.body, error);
}

[NotificationCenter.sharedInstance postNotificationWithIdentifier:[dictionary[@"notificationID"] stringValue]
title:dictionary[@"title"]
Expand Down

0 comments on commit d561d9f

Please sign in to comment.