-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
The default 'alert' module no longer displays rendered HTML data for 'title' or 'message' parameters #3064
Comments
Thanks @khassel for pointing out the It is still an issue with the 'title' parameter but the 'message' parameter has been fixed with #3018 The 'title' parameter can be fixed using the same approach of using the 'safe' filter I'm also wondering if we want to use the 'safe' filter by default without giving the user the option to disable it (?) If, for whatever reason, the user wants to display for example "<iframe id="myWebsite"> is returning a 404" as an alert, the iframe tag would be rendered instead of a text string |
My proposal would be to render 'title' and 'message' as HTML by default unless the notification payload contains 'titleType' / 'messageType' as 'text' such as:
|
alert.njk
|
notification.njk
|
LGTM but please provide a PR (against |
I made slight changes to render HTML by default as that is more preferred and avoids breaking the current behavior. PR is listed above |
Fixes [#3064](#3064) - Fixes default alert module nunjucks templates to render HTML by default unless 'titleType' and 'messageType' are set to 'text' in the payload data e.g. Display Text: `this.sendNotification('SHOW_ALERT', {type: "notification", title: "<u>YoLink LeakSensor</u>", titleType: "text", message: "<b>" + deviceName + "</b> reported an alarm that needs attention.", messageType: "text"});` Display HTML: `this.sendNotification('SHOW_ALERT', {type: "notification", title: "<u>YoLink LeakSensor</u>", message: "<b>" + deviceName + "</b> reported an alarm that needs attention."});`
Update alert / notification table to include 'titleType' and 'messageType' based on MagicMirror Issue MagicMirrorOrg/MagicMirror#3064
* Update alert.md Update alert / notification table to include 'titleType' and 'messageType' based on MagicMirror Issue MagicMirrorOrg/MagicMirror#3064 * Update alert.md Updated to move important from messageType to message * Cleanup and add default values --------- Co-authored-by: veeck <michael.veeck@nebenan.de>
I found a bug in MagicMirror
Platform:
Node Version: 18.15.0
MagicMirror² Version: 2.22.0
Description: The default 'alert' module and documentation (https://docs.magicmirror.builders/modules/alert.html) state that 'title' and 'message' parameters can contain either 'text' or 'html' data. However, when either 'title' or 'message' contain HTML, the HTML tags are displayed as text strings and they are not rendered. This issue was also brought to attention on the forum post at: https://forum.magicmirror.builders/topic/16336/alert-module-no-longer-accepts-html-for-notifications?_=1678593148680
Steps to Reproduce:
From any module, broadcast a notification / alert that contains HTML data in either the 'title' or 'message' parameters such as:
self.sendNotification("SHOW_ALERT", {title: '<u>Welcome</u>', message: '<b>Hello, Nick</b>'});
or
self.sendNotification('SHOW_ALERT', {type: 'notification', title: '<u>Welcome</u>', message: '<b>Hello, Nick</b>'});
Expected Results: The 'alert' module should display rendered HTML for both 'title' and / or 'message' parameters
Actual Results: Both 'text' and 'message' parameters are rendered as text strings (e.g. "Welcome" does not show an underlined title and "Hello, Nick" does not show the text as bold. Instead, each display the HTML tags to the interface as strings)
Configuration:
Additional Notes: This was more than likely caused by the updates to use nunjucks templates over straight HTML as stated in the forum post. I have a fix already in progress that I'll be pushing up shortly to the repo.
The text was updated successfully, but these errors were encountered: