Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3491433
D6398.id21404.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6398.id21404.diff
View Options
diff --git a/keyserver/src/responders/message-responders.js b/keyserver/src/responders/message-responders.js
--- a/keyserver/src/responders/message-responders.js
+++ b/keyserver/src/responders/message-responders.js
@@ -3,6 +3,7 @@
import invariant from 'invariant';
import t from 'tcomb';
+import { onlyOneEmojiRegex } from 'lib/shared/emojis';
import { createMediaMessageData, trimMessage } from 'lib/shared/message-utils';
import { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils';
import type { Media } from 'lib/types/media-types.js';
@@ -20,11 +21,7 @@
import type { TextMessageData } from 'lib/types/messages/text';
import { threadPermissions } from 'lib/types/thread-types';
import { ServerError } from 'lib/utils/errors';
-import {
- tString,
- tShape,
- tMediaMessageMedia,
-} from 'lib/utils/validation-utils';
+import { tRegex, tShape, tMediaMessageMedia } from 'lib/utils/validation-utils';
import createMessages from '../creators/message-creator';
import { SQL } from '../database/database';
@@ -194,7 +191,7 @@
threadID: t.String,
localID: t.maybe(t.String),
targetMessageID: t.String,
- reaction: tString('π'),
+ reaction: tRegex(onlyOneEmojiRegex),
action: t.enums.of(['add_reaction', 'remove_reaction']),
});
async function reactionMessageCreationResponder(
diff --git a/lib/shared/emojis.js b/lib/shared/emojis.js
--- a/lib/shared/emojis.js
+++ b/lib/shared/emojis.js
@@ -9,6 +9,8 @@
'could not extract innerEmojiRegex from emoji-regex.js',
);
const innerEmojiRegexString = emojiRegexMatches[1];
+
const onlyEmojiRegex: RegExp = new RegExp(`^(${innerEmojiRegexString})+$`);
+const onlyOneEmojiRegex: RegExp = new RegExp(`^(${innerEmojiRegexString})$`);
-export { onlyEmojiRegex };
+export { onlyEmojiRegex, onlyOneEmojiRegex };
diff --git a/lib/shared/emojis.test.js b/lib/shared/emojis.test.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/emojis.test.js
@@ -0,0 +1,25 @@
+// @flow
+
+import { onlyOneEmojiRegex } from './emojis';
+
+describe('onlyOneEmojiRegex', () => {
+ it('should match for (π)', () => {
+ expect('π').toMatch(onlyOneEmojiRegex);
+ });
+
+ it('should match for (π«‘)', () => {
+ expect('π«‘').toMatch(onlyOneEmojiRegex);
+ });
+
+ it('should match for (π¦ΆπΎ)', () => {
+ expect('π¦ΆπΎ').toMatch(onlyOneEmojiRegex);
+ });
+
+ it('should not match for (π¦ΆπΎπ)', () => {
+ expect('π¦ΆπΎπ').not.toMatch(onlyOneEmojiRegex);
+ });
+
+ it('should not match for (that is π₯)', () => {
+ expect('that is π₯').not.toMatch(onlyOneEmojiRegex);
+ });
+});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 7:17 PM (21 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678258
Default Alt Text
D6398.id21404.diff (2 KB)
Attached To
Mode
D6398: [keyserver] change reaction type from just like emoji to any emoji
Attached
Detach File
Event Timeline
Log In to Comment