diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-07-20 13:52:13 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-07-20 14:05:10 +0200 |
commit | 0ad74590d4b7d91189a08d2278aaa6093d0a7e22 (patch) | |
tree | 86b4678bfb1d27d1346ef0bdfa419bce8fba4721 /src/timeline/TimelineModel.cpp | |
parent | Merge pull request #1121 from MayeulC/32bit (diff) | |
download | nheko-0ad74590d4b7d91189a08d2278aaa6093d0a7e22.tar.xz |
Fix matrix.to link escaping
Properly escapes in replies and with unmatched []. fixes #854
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r-- | src/timeline/TimelineModel.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index c60940a7..b2798e26 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -2625,6 +2625,8 @@ TimelineModel::setEdit(const QString &newEdit) nhlog::ui()->debug("Stored: {}", textBeforeEdit.toStdString()); } + auto quoted = [](QString in) { return in.replace("[", "\\[").replace("]", "\\]"); }; + if (edit_ != newEdit) { auto ev = events.get(newEdit.toStdString(), ""); if (ev && mtx::accessors::sender(*ev) == http::client()->user_id().to_string()) { @@ -2649,7 +2651,7 @@ TimelineModel::setEdit(const QString &newEdit) for (const auto &[user, link] : reverseNameMapping) { // TODO(Nico): html unescape the user name - editText.replace(user, QStringLiteral("[%1](%2)").arg(user, link)); + editText.replace(user, QStringLiteral("[%1](%2)").arg(quoted(user), link)); } } |