fix: Emoji regex incorrectly using multiline

This commit is contained in:
Sorunome 2020-09-20 19:09:32 +02:00
parent ba7a01ddea
commit d42979da12
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
2 changed files with 15 additions and 4 deletions

View file

@ -781,19 +781,19 @@ class Event extends MatrixEvent {
static final RegExp _onlyEmojiRegex = RegExp(
r'^(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|\s)*$',
caseSensitive: false,
multiLine: true);
multiLine: false);
static final RegExp _onlyEmojiEmoteRegex = RegExp(
r'^(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|<img[^>]+data-mx-(?:emote|emoticon)(?==|>|\s)[^>]*>|\s)*$',
caseSensitive: false,
multiLine: true);
multiLine: false);
static final RegExp _countEmojiRegex = RegExp(
r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])',
caseSensitive: false,
multiLine: true);
multiLine: false);
static final RegExp _countEmojiEmoteRegex = RegExp(
r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]|<img[^>]+data-mx-(?:emote|emoticon)(?==|>|\s)[^>]*>)',
caseSensitive: false,
multiLine: true);
multiLine: false);
/// Returns if a given event only has emotes, emojis or whitespace as content.
/// This is useful to determine if stand-alone emotes should be displayed bigger.

View file

@ -1171,6 +1171,17 @@ void main() {
}, null);
expect(event.onlyEmotes, false);
expect(event.numberEmotes, 0);
event = Event.fromJson({
'type': EventTypes.Message,
'content': {
'msgtype': 'm.text',
'body': 'normal message\n\nvery normal',
},
'event_id': '\$edit2',
'sender': '@alice:example.org',
}, null);
expect(event.onlyEmotes, false);
expect(event.numberEmotes, 0);
event = Event.fromJson({
'type': EventTypes.Message,
'content': {