diff --git a/apps/meteor/server/lib/parseMessageSearchQuery.ts b/apps/meteor/server/lib/parseMessageSearchQuery.ts index bed8d9351240d..56b5161746fd2 100644 --- a/apps/meteor/server/lib/parseMessageSearchQuery.ts +++ b/apps/meteor/server/lib/parseMessageSearchQuery.ts @@ -45,7 +45,9 @@ class MessageSearchQueryParser { from.push(username); // Search for case-sensitive prefix match (no substrings) - this.query['u.username'] = { $in: from.map((prefix) => RegExp(`^${prefix}`)) }; + this.query['u.username'] = { + $in: from.map((prefix) => RegExp(`^${prefix.replace(/\./g, '\\.')}`)), + }; return ''; }); diff --git a/apps/meteor/server/methods/messageSearch.ts b/apps/meteor/server/methods/messageSearch.ts index f2dda3882d2d6..50f238081150f 100644 --- a/apps/meteor/server/methods/messageSearch.ts +++ b/apps/meteor/server/methods/messageSearch.ts @@ -36,7 +36,12 @@ Meteor.methods({ if (!(await canAccessRoomIdAsync(rid, currentUserId))) { return false; } - } else if (settings.get('Search.defaultProvider.GlobalSearchEnabled') !== true) { + } else if ( + settings.get('Search.defaultProvider.GlobalSearchEnabled') !== true || + text.length < 3 || + text.match(/^from?$/i) || + text.match(/^from:[a-z0-9.\-_]{0,2}$/i) + ) { return { message: { docs: [], @@ -53,7 +58,7 @@ Meteor.methods({ forceRegex: settings.get('Message_AlwaysSearchRegExp'), }); - if (text.length < 3 || Object.keys(query).length === 0) { + if (Object.keys(query).length === 0) { return { message: { docs: [],