https://bugs.kde.org/show_bug.cgi?id=523972
Bug ID: 523972
Summary: Phone notifications show raw HTML tags (`<br/>`)
instead of line breaks
Classification: KDE Neon
Product: neon
Version First unspecified
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: general
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
Target Milestone: ---
**related to bugs.kde.org #420221**
**Summary**
Notifications relayed from the phone are HTML-escaped by kdeconnectd before
being forwarded to the notification server, so the `<br/>` line breaks that
Android apps put in notification text are displayed as **literal text** — the
body comes out as one long line with visible tags. This hits every desktop
whose notification server renders the body as markup (GNOME Shell, Cinnamon,
dunst, ...). See also bugs.kde.org #420221 (still open/UNCONFIRMED since 2020)
and #400923 (claimed "fixed in 1.4", but the escaping is back in the current
code).
**Evidence** (dbus capture of what kdeconnectd sends to
org.freedesktop.Notifications, kdeconnect 26.04.3, Messenger notification from
Android):
```
string "KDE Connect"
string "Messenger"
string "D.S.: kurwa<br/>od teraz bede płacił już duży
ZUS<br/>...<br/>świetna rada"
```
The phone sends plain text with `<br/>`; the daemon escapes it to
`<br/>`; the server decodes the entity and displays the literal string
`<br/>`.
**Root cause**
`plugins/notifications/notification.cpp`,
`Notification::createKNotification()`:
```cpp
QString escapedTitle = m_title.toHtmlEscaped();
QString escapedText = m_text.toHtmlEscaped();
```
`m_text` can legitimately contain `<br/>` (Android apps use it for line breaks,
and for conversation notifications kdeconnect itself builds
`<b>sender</b><br/>...` markup in `getConversationMessages()`).
`toHtmlEscaped()` turns those into `<br/>`/`<b>`, which
body-markup-capable servers decode back into literal tags. The KDE path only
avoids this for conversations (unescaped `m_text` when the server reports
`X_KDE_DISPLAY_APPNAME`).
**Proposed fix** (what we currently run locally — converts line breaks to real
newlines and drops the b/i/u tags, keeping the body plain for non-KDE servers):
```diff
--- a/plugins/notifications/notification.cpp
+++ b/plugins/notifications/notification.cpp
@@
QString escapedTitle = m_title.toHtmlEscaped();
// notification title text does not have markup, but in some cases below
it is used in body text so we escape it
- QString escapedText = m_text.toHtmlEscaped();
+ QString escapedText = m_text;
+ escapedText.replace(QStringLiteral("<br/>"), QStringLiteral("\n"));
+ escapedText.replace(QStringLiteral("<br>"), QStringLiteral("\n"));
+ escapedText.replace(QStringLiteral("<b>"), QString());
+ escapedText.replace(QStringLiteral("</b>"), QString());
+ escapedText.replace(QStringLiteral("<i>"), QString());
+ escapedText.replace(QStringLiteral("</i>"), QString());
+ escapedText.replace(QStringLiteral("<u>"), QString());
+ escapedText.replace(QStringLiteral("</u>"), QString());
+ escapedText = escapedText.toHtmlEscaped();
QString escapedTicker = m_ticker.toHtmlEscaped();
```
An arguably cleaner alternative: strip all HTML from the phone text up front
(`<br/>` -\> `\n`) and keep sending unescaped markup only on KDE servers, as
the conversation path already does via the `X_KDE_DISPLAY_APPNAME` hint.
**Environment:** kdeconnect 26.04.3 (KDE Gear), Cinnamon 6.x. Reproducible on
any server advertising the `body-markup` capability.
--
You are receiving this mail because:
You are watching all bug changes.