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

Fix bugs in web title and message templates rendering and visual representation #1747

Merged
merged 17 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed bugs
iskhakov committed Apr 19, 2023

Verified

This commit was signed with the committer’s verified signature.
rezkiy37 Michael (Mykhailo) Kravchenko
commit 6a634fb84775e43f9349d19d671170b357cfec35
11 changes: 6 additions & 5 deletions engine/common/utils.py
Original file line number Diff line number Diff line change
@@ -168,13 +168,14 @@ def convert_md_to_html(text):
# This gives us <pre> and <code> tags for ```-fenced blocks
"fenced-code-blocks",
"pyshell",
"nl2br",
"target-blank-links",
"nofollow",
"pymdownx.emoji",
"pymdownx.magiclink",
"tables",
],
).strip()
# Special handling cases for lists
text = text.replace("\n\n<ul>", "<ul>")
text = text.replace("\n<li>", "<li>")
# Special handling cases for newlines
text = text.replace("\n", "<br/>")
return text


20 changes: 19 additions & 1 deletion engine/config_integrations/alertmanager.py
Original file line number Diff line number Diff line change
@@ -47,9 +47,27 @@
**🏷️ Labels:**
```
{% for k, v in payload["labels"].items() -%}
{%- for k, v in payload["labels"].items() %}
{{ k }}={{ v }}
{%- endfor %}
```
{%- if annotations |length > 0%}
**Other annotations:**
{% for k, v in payload["annotations"].items() %}
{#- render annotation as markdown url if it starts with http #}
- *{{ k }}*: {% if v.startswith("http") %} [here]({{v}}){% else %} {{v}} {% endif -%}
{% endfor %}
{% endif %}
```
{%- if annotations |length > 0%}
**Other annotations:**
{% for k, v in payload["annotations"].items() %}
{#- render annotation as markdown url if it starts with http #}
- *{{ k }}*: {% if v.startswith("http") %} [here]({{v}}){% else %} {{v}} {% endif -%}
{% endfor %}
{% endif %}
```
{%- if annotations |length > 0%}
1 change: 1 addition & 0 deletions engine/requirements.txt
Original file line number Diff line number Diff line change
@@ -52,3 +52,4 @@ django-dbconn-retry==0.1.7
django-ipware==4.0.2
django-anymail==8.6
django-deprecate-fields==0.1.1
pymdown-extensions==9.11
2 changes: 1 addition & 1 deletion grafana-plugin/src/utils/sanitize.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import dompurify from 'dompurify';
export default function sanitize(str: string): string {
return dompurify.sanitize(str, {
USE_PROFILES: { html: true },
FORBID_TAGS: ['form', 'input', 'pre'],
FORBID_TAGS: ['form', 'input'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maskin25 can you approve this change?

ADD_ATTR: ['target'],
});
}