Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord notifications look wrong #729

Open
goose121 opened this issue Jul 2, 2020 · 8 comments
Open

Discord notifications look wrong #729

goose121 opened this issue Jul 2, 2020 · 8 comments
Labels
Milestone

Comments

@goose121
Copy link

goose121 commented Jul 2, 2020

It seems that Discord escapes some markup characters, including apostrophes, but does not properly escape angle brackets. This means that without setting markup = strip, any message with angle brackets will render incorrectly, but when setting markup = strip, any character Discord does escape shows up as an HTML entity in the notification (e.g. a notification will say "aren&#39t" instead of "aren't").

One solution I have tried was to use the script attribute together with a script which replaced the angle brackets with their HTML entity representation then sent a new notification, using its command line arguments for the information. However, this did not work very well because it seems that the custom icons used by Discord are not passed in to the script as the icon argument is empty. Additionally, Discord replaces certain old notifications in a channel with new ones, but since this solution replaces the notification entirely, including its ID, that does not work.

One possible solution to similar issues where modifying the content or other attributes of a notification in arbitrary ways is desirable could be to allow scripts to modify the attributes of a notification, rather than simply replacing the notification. This could potentially be done by having the script print the desired attributes to standard output (possibly null-separated).

I am running version 1.4.1 of Dunst on Artix Linux (which is basically Arch but with OpenRC).

@tsipinakis
Copy link
Member

Well markup = strip should have worked, but our parser is simplistic and only understands ' for apostrophes.

Why not set markup = full? This will hand over the parsing to pango and should support/properly display all characters along with formatting?

@tsipinakis
Copy link
Member

One possible solution to similar issues where modifying the content or other attributes of a notification in arbitrary ways is desirable could be to allow scripts to modify the attributes of a notification, rather than simply replacing the notification.

All in all, I'm also open to this idea, it would allow for some interesting customizations, perhaps even alternative rule implementations.

@goose121
Copy link
Author

goose121 commented Jul 2, 2020

Why not set markup = full? This will hand over the parsing to pango and should support/properly display all characters along with formatting?

Discord doesn't properly escape angle brackets in notifications, which confuses pango (I've opened a bug with them as well, but it would be nice to be able to work around things like this with scripts).

@tsipinakis
Copy link
Member

tsipinakis commented Jul 3, 2020

For this issue I see 2 ways forward, either the solution mentioned above (implementing filter scripts), or expanding our makeshift markup parser to accept all escaped characters, I'm fine with both, however I don't know when/if I'll pick this one up but I am open to PRs.

For the first one, the person implementing it can use notification_run_script as a reference, however I think I'd prefer json over NULL-separated values as it gives more flexibility (and preferably using a single-header/simple C library to avoid adding extra dependencies just for that).

For the second solution, the quote/unqote functions would need to be expanded in the markup parser. Edit: On second thought on this, this would also involve modifying the parser so it doesn't strip out arbitrary tags, the spec says not to use them anyway so this change should be fine (but not simple), otherwise any unescaped <...> will end up getting stripped out. So I retract that, let's focus on the filter scripts instead, much more flexible.

@Lordfirespeed
Copy link

Hey, I'm thinking of taking a look at this - You mentioned you'd prefer JSON; am I OK to implement using a JSON for C library such as

and do you have a preference for which library to use?

@bynect
Copy link
Member

bynect commented Sep 12, 2024

is this issue still relevant?

@goose121
Copy link
Author

Yes

@bynect
Copy link
Member

bynect commented Sep 12, 2024

Discord doesn't properly escape angle brackets in notifications, which confuses pango (I've opened a bug with them as well, but it would be nice to be able to work around things like this with scripts).

what happened in the bug report with pango?

@bynect bynect added this to the v2.0 milestone Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants