ircd:Ⓜ️:room::message: Fix reply fallback accepting non-mxid careted names.

This commit is contained in:
Jason Volk 2022-09-21 16:30:01 -07:00
parent 2a608b8a7c
commit 6092fabe42
2 changed files with 23 additions and 7 deletions

View File

@ -44,6 +44,10 @@ struct ircd::m::room::message
/// not a reply. If malformed, the message is not considered a reply. /// not a reply. If malformed, the message is not considered a reply.
id::event reply_to_event() const noexcept; id::event reply_to_event() const noexcept;
/// The user who sent the message being replied to; empty if not a reply
/// or the name was missing.
string_view reply_to_name() const noexcept;
/// The user who sent the message being replied to; empty if not a reply /// The user who sent the message being replied to; empty if not a reply
/// or the username was missing or malformed. /// or the username was missing or malformed.
id::user reply_to_user() const noexcept; id::user reply_to_user() const noexcept;

View File

@ -110,12 +110,12 @@ ircd::string_view
ircd::m::room::message::reply_to_body() ircd::m::room::message::reply_to_body()
const noexcept const noexcept
{ {
const auto reply_to_user const auto reply_to_name
{ {
this->reply_to_user() this->reply_to_name()
}; };
if(likely(!reply_to_user)) if(likely(!reply_to_name))
return {}; return {};
string_view body string_view body
@ -125,7 +125,7 @@ const noexcept
body = string_view body = string_view
{ {
reply_to_user.end(), body.end() reply_to_name.end(), body.end()
}; };
tokens(body, "\\n", [&body] tokens(body, "\\n", [&body]
@ -148,6 +148,21 @@ const noexcept
ircd::m::user::id ircd::m::user::id
ircd::m::room::message::reply_to_user() ircd::m::room::message::reply_to_user()
const noexcept const noexcept
{
const auto reply_to_name
{
this->reply_to_name()
};
if(!valid(m::id::USER, reply_to_name))
return {};
return reply_to_name;
}
ircd::string_view
ircd::m::room::message::reply_to_name()
const noexcept
{ {
string_view body string_view body
{ {
@ -166,9 +181,6 @@ const noexcept
between(body, '<', '>') between(body, '<', '>')
}; };
if(!valid(m::id::USER, ret))
return {};
return ret; return ret;
} }