diff options
-rw-r--r-- | lib/events/roommessageevent.cpp | 2 | ||||
-rw-r--r-- | lib/uri.cpp | 15 | ||||
-rw-r--r-- | quotest/quotest.cpp | 4 |
3 files changed, 16 insertions, 5 deletions
diff --git a/lib/events/roommessageevent.cpp b/lib/events/roommessageevent.cpp index a9d9754f..31c0fd9e 100644 --- a/lib/events/roommessageevent.cpp +++ b/lib/events/roommessageevent.cpp @@ -300,7 +300,7 @@ TextContent::TextContent(const QJsonObject& json) const auto actualJson = isReplacement(relatesTo) ? json.value("m.new_content"_ls).toObject() : json; - // Special-casing the custom matrix.org's (actually, Riot's) way + // Special-casing the custom matrix.org's (actually, Element's) way // of sending HTML messages. if (actualJson["format"_ls].toString() == HtmlContentTypeId) { mimeType = HtmlMimeType; diff --git a/lib/uri.cpp b/lib/uri.cpp index 4b171e79..291bfcae 100644 --- a/lib/uri.cpp +++ b/lib/uri.cpp @@ -10,13 +10,19 @@ using namespace Quotient; struct ReplacePair { QByteArray uriString; char sigil; }; -/// Defines bi-directional mapping of path prefixes and sigils +/// \brief Defines bi-directional mapping of path prefixes and sigils +/// +/// When there are two prefixes for the same sigil, the first matching +/// entry for a given sigil is used. static const auto replacePairs = { - ReplacePair { "user/", '@' }, + ReplacePair { "u/", '@' }, + { "user/", '@' }, { "roomid/", '!' }, + { "r/", '#' }, { "room/", '#' }, // The notation for bare event ids is not proposed in MSC2312 but there's // https://github.com/matrix-org/matrix-doc/pull/2644 + { "e/", '$' }, { "event/", '$' } }; @@ -97,7 +103,7 @@ Uri::Uri(QUrl url) : QUrl(std::move(url)) case 2: break; case 4: - if (splitPath[2] == "event") + if (splitPath[2] == "event" || splitPath[2] == "e") break; [[fallthrough]]; default: @@ -150,7 +156,8 @@ Uri::Type Uri::type() const { return primaryType_; } Uri::SecondaryType Uri::secondaryType() const { - return pathSegment(*this, 2) == "event" ? EventId : NoSecondaryId; + const auto& type2 = pathSegment(*this, 2); + return type2 == "event" || type2 == "e" ? EventId : NoSecondaryId; } QUrl Uri::toUrl(UriForm form) const diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp index bf29c434..a0914c72 100644 --- a/quotest/quotest.cpp +++ b/quotest/quotest.cpp @@ -733,12 +733,15 @@ TEST_IMPL(visitResources) roomId, "matrix:roomid/" + roomId.mid(1), "https://matrix.to/#/%21"/*`!`*/ + roomId.mid(1), roomAlias, "matrix:room/" + roomAlias.mid(1), + "matrix:r/" + roomAlias.mid(1), "https://matrix.to/#/" + roomAlias, }; const QStringList userUris { userId, "matrix:user/" + userId.mid(1), + "matrix:u/" + userId.mid(1), "https://matrix.to/#/" + userId }; const QStringList eventUris { "matrix:room/" + roomAlias.mid(1) + "/event/" + eventId.mid(1), + "matrix:r/" + roomAlias.mid(1) + "/e/" + eventId.mid(1), "https://matrix.to/#/" + roomId + '/' + eventId }; // Check that reserved characters are correctly processed. @@ -752,6 +755,7 @@ TEST_IMPL(visitResources) static const QStringList joinByAliasUris { Uri(joinRoomAlias.toUtf8(), {}, joinQuery.mid(1)).toDisplayString(), "matrix:room/" + encodedRoomAliasNoSigil + joinQuery, + "matrix:r/" + encodedRoomAliasNoSigil + joinQuery, "https://matrix.to/#/%23"/*`#`*/ + encodedRoomAliasNoSigil + joinQuery, "https://matrix.to/#/%23" + joinRoomAlias.mid(1) /* unencoded */ + joinQuery }; |