From a44bef5796a21b7b5c65536497b8181bc3db14f9 Mon Sep 17 00:00:00 2001 From: purian23 Date: Sun, 31 May 2026 22:38:50 -0400 Subject: [PATCH] fix(Notifications): restore long message content from overflowing - Addtional security escape patch - Tweak Notification Center width --- quickshell/Modals/DankLauncherV2/Controller.qml | 8 ++++++-- .../Center/HistoryNotificationCard.qml | 7 ++++--- .../Notifications/Center/NotificationCard.qml | 14 ++++++++------ .../Center/NotificationCenterPopout.qml | 2 +- .../Notifications/Popup/NotificationPopup.qml | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/quickshell/Modals/DankLauncherV2/Controller.qml b/quickshell/Modals/DankLauncherV2/Controller.qml index 681b29a0..2242782a 100644 --- a/quickshell/Modals/DankLauncherV2/Controller.qml +++ b/quickshell/Modals/DankLauncherV2/Controller.qml @@ -1721,11 +1721,15 @@ Item { return ""; var idx = text.toLowerCase().indexOf(lowerQuery); if (idx === -1) - return text; + return _escapeRichText(text); var before = text.substring(0, idx); var match = text.substring(idx, idx + queryLen); var after = text.substring(idx + queryLen); - return '' + before + '' + match + '' + after + ''; + return '' + _escapeRichText(before) + '' + _escapeRichText(match) + '' + _escapeRichText(after) + ''; + } + + function _escapeRichText(text) { + return String(text).replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } function getCurrentSectionViewMode() { diff --git a/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml b/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml index 15ee3e76..be55f2e8 100644 --- a/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml +++ b/quickshell/Modules/Notifications/Center/HistoryNotificationCard.qml @@ -99,8 +99,9 @@ Rectangle { id: contentItem readonly property real expandedTextHeight: descriptionText.contentHeight - readonly property real twoLineHeight: descriptionText.font.pixelSize * 1.2 * 2 - readonly property real extraHeight: (descriptionExpanded && expandedTextHeight > twoLineHeight + 2) ? (expandedTextHeight - twoLineHeight) : 0 + readonly property real collapsedLineCount: compactMode ? 1 : 2 + readonly property real collapsedLineHeight: descriptionText.font.pixelSize * 1.2 * collapsedLineCount + readonly property real extraHeight: (descriptionExpanded && expandedTextHeight > collapsedLineHeight + 2) ? (expandedTextHeight - collapsedLineHeight) : 0 anchors.top: parent.top anchors.left: parent.left @@ -229,7 +230,7 @@ Rectangle { property bool hasMoreText: truncated text: historyItem.htmlBody || historyItem.body || "" - textFormat: Text.RichText + textFormat: Text.StyledText color: Theme.surfaceVariantText font.pixelSize: Theme.fontSizeSmall width: parent.width diff --git a/quickshell/Modules/Notifications/Center/NotificationCard.qml b/quickshell/Modules/Notifications/Center/NotificationCard.qml index a7705ea5..22a3e285 100644 --- a/quickshell/Modules/Notifications/Center/NotificationCard.qml +++ b/quickshell/Modules/Notifications/Center/NotificationCard.qml @@ -395,7 +395,7 @@ Rectangle { property bool hasMoreText: truncated text: fullText - textFormat: Text.RichText + textFormat: Text.StyledText color: Theme.surfaceVariantText font.pixelSize: Theme.fontSizeSmall width: parent.width @@ -561,9 +561,9 @@ Rectangle { height: { if (!messageExpanded) return expandedBaseHeight; - const twoLineHeight = bodyText.font.pixelSize * 1.2 * 2; - if (bodyText.implicitHeight > twoLineHeight + 2) - return expandedBaseHeight + bodyText.implicitHeight - twoLineHeight; + const collapsedBodyHeight = bodyText.collapsedLineHeight; + if (bodyText.implicitHeight > collapsedBodyHeight + 2) + return expandedBaseHeight + bodyText.implicitHeight - collapsedBodyHeight; return expandedBaseHeight; } radius: Theme.cornerRadius @@ -703,15 +703,17 @@ Rectangle { StyledText { id: bodyText + readonly property real collapsedLineCount: compactMode ? 1 : 2 + readonly property real collapsedLineHeight: font.pixelSize * 1.2 * collapsedLineCount property bool hasMoreText: truncated text: modelData?.htmlBody || "" - textFormat: Text.RichText + textFormat: Text.StyledText color: Theme.surfaceVariantText font.pixelSize: Theme.fontSizeSmall width: parent.width elide: messageExpanded ? Text.ElideNone : Text.ElideRight - maximumLineCount: messageExpanded ? -1 : 2 + maximumLineCount: messageExpanded ? -1 : collapsedLineCount wrapMode: Text.WrapAtWordBoundaryOrAnywhere visible: text.length > 0 linkColor: Theme.primary diff --git a/quickshell/Modules/Notifications/Center/NotificationCenterPopout.qml b/quickshell/Modules/Notifications/Center/NotificationCenterPopout.qml index 9c1c7672..012a1e1f 100644 --- a/quickshell/Modules/Notifications/Center/NotificationCenterPopout.qml +++ b/quickshell/Modules/Notifications/Center/NotificationCenterPopout.qml @@ -50,7 +50,7 @@ DankPopout { } } - popupWidth: 400 + popupWidth: 400 + Theme.spacingL popupHeight: stablePopupHeight positioning: "" suspendShadowWhileResizing: false diff --git a/quickshell/Modules/Notifications/Popup/NotificationPopup.qml b/quickshell/Modules/Notifications/Popup/NotificationPopup.qml index e3d0d484..43d24f9b 100644 --- a/quickshell/Modules/Notifications/Popup/NotificationPopup.qml +++ b/quickshell/Modules/Notifications/Popup/NotificationPopup.qml @@ -755,7 +755,7 @@ PanelWindow { visible: false width: Math.max(0, backgroundContainer.width - Theme.spacingL - (Theme.spacingL + Theme.notificationHoverRevealMargin) - popupIconSize - Theme.spacingM) text: notificationData ? (notificationData.htmlBody || "") : "" - textFormat: Text.RichText + textFormat: Text.StyledText font.pixelSize: Theme.fontSizeSmall elide: Text.ElideNone horizontalAlignment: Text.AlignLeft @@ -913,7 +913,7 @@ PanelWindow { property bool hasMoreText: truncated text: notificationData ? (notificationData.htmlBody || "") : "" - textFormat: Text.RichText + textFormat: Text.StyledText color: Theme.surfaceVariantText font.pixelSize: Theme.fontSizeSmall width: parent.width