Comments (5)
Thanks for this discover.
So as you suggested in Bug 858519, text should be filter out before passing data to libnotify. I would be very appreciated if you could propose javascript function that can do such filtering.
from gnotifier.
I have no experience with Firefox internals but I'll do what I can. (almost a decade ago, I tried to write extensions and found the API documentation and tooling discouragingly awful. Since the Jetpack SDK came out, I haven't needed to write an extension.)
I ran out of time today, but here's the partly-pseudo code I was able to come up with in the time given. (eg. No HTML sanitization yet and it just assumes that the notification daemon has the IMAGE_SVG capability when the site provides an SVG icon rather than rasterizing it)
The more you can clarify what you need me to do, the more I can focus my efforts.
// --== Stuff you'll probably want to call once on init ==--
var capabilities = notify_get_server_caps();
var server_info = notify_get_server_info();
var clean_markup = function(dom_node) {
// TODO: Maybe tomorrow.
};
// --== Stuff to call each time ==--
var title = title_as_provided_by_the_api;
var body_dom = dom_firefox_generates_for_internal_notification_renderer;
var icon = icon_as_provided_by_the_api;
if (capabilities.index_of('body-markup') === -1) {
// I'm too used to jQuery to write this on my own but here's the relevant bit of jQuery().text()
// http://stackoverflow.com/a/5023626
var notification = new NotifyNotification(
title,
jQuery(body_dom).text(),
icon);
} else {
var notification = new NotifyNotification(
title,
clean_markup(body_dom),
icon);
}
if (capabilities.index_of('actions') !== -1 and server_info.name !== 'notify-osd') {
// This name-matching is really how Unity's notify-osd expects you to manage its dysfunctional
// "if there are actions, show an old-style dialog" behaviour.
var actions = body_dom.querySelectorAll(
'input[type="submit"], input[type="button"], button');
for (var i = 0; i < actions.length; ++i) {
var dom_node = actions[i];
var action_id = /* Whatever code you use to reconcile DOM and GTK+ events */
var action_callback = /* Whatever code you use to reconcile DOM and GTK+ events */
notification.add_action(
action_id,
jQuery(dom_node).text(),
action_callback);
}
}
Since I ran out of time before implementing it, here's what render_markup
must do:
- Replace
<img>
tags with the contents of theiralt
attributes unlessbody-images
is present in the capabilities. - Subject to the effects of other rules like
body-images
, remove any elements which are neither text nor<b>
,<big>
,<i>
,<sub>
,<sup>
,<small>
,<span>
,<tt>
,<u>
, or<s>
and hoist their children to become children of their parent node. - Remove all attributes except
<img src="">
(assumingbody-images
) and<a href="">
(assumingbody-hyperlinks
). - Use a regex like
sub('\s+', ' ')
to perform HTML-like normalization on text nodes since Pango renders as ifwhite-space: pre
is in effect. - Replace
<br>
and<p>
with\n
since that's how Pango insists newlines be represented. - If the host is GNOME Shell (I'm not sure what the exact
server_info.name
value is), filter markup further to only<b>
,<i>
, and<u>
or it'll treat other tags as stuff like<big>
.
from gnotifier.
As my not commenting yesterday implied, I'm a bit busy. Do you want me to wait until I can give code for clean_markup
that will actually run or will pseudocode do?
(All my DOM manipulation experience is using either jQuery or the Python LXML DOM library so familiarizing myself with the W3C DOM API is a very non-trivial portion of the time it'll take.)
from gnotifier.
I think I have enough information (from you) and can do this dirty work by myself :-) Many thanks for your involvement!
from gnotifier.
Finally, the issue has been fixed in the latest dev xpi. It took me only 4 years! ;-)
from gnotifier.
Related Issues (20)
- [Feature Request] List of inboxes to exclude HOT 2
- [Firefox] GNotifier 1.11.0 is marked as outdated HOT 2
- exchange pictures for thunderbird ones HOT 2
- Thunderbird message %a produces invalid HTML HOT 7
- custom command arguments not escaped HOT 2
- Seamonkey: console.error: gnotifier: Notification API init has failed! HOT 9
- structure descriptions and pretty print settings more HOT 3
- [SeaMonkey] Notifications are unchanged HOT 3
- GNotifier not working in new Firefox 57 HOT 10
- Problem related to character encoding HOT 4
- Add support for Firefox Quantum+ HOT 2
- Does not work at all in Thunderbird 52.6.0 on Arch HOT 17
- Support X11 urgency hint on Linux HOT 6
- Support for Firefox Quantum (webextensions) HOT 1
- Plugin won't load - optionsType not supported HOT 1
- Thunderbird 60 ESR support HOT 2
- "Select on list" for "open action" does not put Thunderbird in foreground (Windows 10)
- [Announcement] GNotifier on Thunderbird 60 HOT 14
- Support for Solaris 11.4 HOT 1
- is there no way to bring gnotifier to 60.x.x? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnotifier.