Add escape code for rich notifications.
This pull request adds support for a "rich" notification escape code. There might a better choice than calling them "rich", but the feature allows more control over notifications than the existing escape code.
I had considered whether it might be better to try to implement this functionality via the "custom" escape code and Python API, and then using another program such as terminal-notifier (https://github.com/julienXX/terminal-notifier) to present the notifications. However, it does not seem possible to get an external tool to focus the correct window/tab when clicking on the notification.
To keep parsing simple, each of the fields for the notification is base64 encoded.
It might make sense to lock this down further with add an allow/deny list for the notification image, similar to what there appears to be for setting a background image. However, I wasn't able to determine where those lists were defined.
It also appears that there the code is using an older deprecated notifications API. It seems better to address that in a separate change though. However, it looks the new API was introduced in Mojave, so I'm not sure if there backwards compatibility implications.
Finally, it has also been quite a long time since I have written much Objective-C, so definitely let me know if there are any improvements to style that I should make.
Thank you for taking this on and I'm sorry it took so long for me to get to it. The only concern I have is about the image. We have to treat input as malicious (since when you ssh somewhere or git push, a remote computer controls the input you receive). We also have to treat image decoding a remote code execution. Since the image has to be local it's less of a concern, but this could be one step in an exploit chain.
To make image decoding safe, use iTermImage instead of creating the NSImage directly:
NSData *data = [NSData dataWithContentsOfFile:image];
notification.contentImage = = [[[iTermImage imageWithCompressedData:data] images] firstObject];
No problem, I've had plenty to keep me busy in the meantime :-)
I've updated the pull request as suggested. Let me know if you think of anything else.
Merged as 8ef95e1b0d9c849a68d76500e91901e97b27b635. Thank you!