From 6b1d6fd55ccc94ce5fcbe64760368fadaaac298e Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Wed, 11 Sep 2024 19:23:48 +0200 Subject: [PATCH] #3105 fix: remove \n sent by web companion when editing bookmark Signed-off-by: Patrizio Bekerle --- CHANGELOG.md | 4 ++++ src/services/websocketserverservice.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 846ba6c8fa..f587559fd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - The name detection of links in checkbox list item for bookmarks for the [Web Companion browser extension](https://github.com/qownnotes/web-companion) was improved (for [#3104](https://github.com/pbek/QOwnNotes/issues/3104)) +- `\n` sent by the [Web Companion browser extension](https://github.com/qownnotes/web-companion) + while editing bookmarks will now be automatically removed to not break the + Markdown link (for [#3105](https://github.com/pbek/QOwnNotes/issues/3105)) + ## 24.9.4 - An issue with the **backlink widget** showing duplicate items panel was fixed (for [#1717](https://github.com/pbek/QOwnNotes/issues/1717)) diff --git a/src/services/websocketserverservice.cpp b/src/services/websocketserverservice.cpp index 2d27bb08dc..111264c255 100644 --- a/src/services/websocketserverservice.cpp +++ b/src/services/websocketserverservice.cpp @@ -428,7 +428,10 @@ int WebSocketServerService::editBookmark(const QJsonObject &jsonObject) { // Get the "markdown" attribute from the "data" object QString markdown = dataObject.value("markdown").toString().trimmed(); - QString newMarkdown = dataObject.value("newMarkdown").toString().trimmed(); + + // Make sure there was no newline character in the string + // https://github.com/pbek/QOwnNotes/issues/3105 + QString newMarkdown = dataObject.value("newMarkdown").toString().remove(QChar('\n')).trimmed(); if (markdown.isEmpty() || newMarkdown.isEmpty()) { return 0;