-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[$250] Web - Compose Box - Emoji only is being accepted as an anchor text #54484
Comments
Triggered auto assignment to @sakluger ( |
We fixed this a long time ago here: #18386 @dukenv0307 and @sobitneupane worked on that issue. Do either of you have any ideas where this regression came from? |
Job added to Upwork: https://www.upwork.com/jobs/~021871677968650628808 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws ( |
@sakluger, I found the PR that caused this issue: Expensify/expensify-common#749. It seems like it's the expectation |
ProposalPlease re-state the problem that we are trying to solve in this issue.The issue appears to be with hyperlinks in the chat. When a user attempts to create a link with only an emoji as the anchor text ( using markdown format [emoji](url)), the app is accepting this as valid when it should not. The core problem seems to be insufficient validation of anchor text in the links. What is the root cause of that problem?The What changes do you think we should make in order to solve the problem?Add a utility function to check for valid anchor text, maybe in const validateEmojiLinks = (text: string): boolean => {
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
let match;
while ((match = linkRegex.exec(text)) !== null) {
const [, linkText] = match;
// Check if the anchor text contains only emojis
const nonEmojiContent = linkText.replace(CONST.REGEX.EMOJI_REGEX, '').trim();
if (nonEmojiContent.length === 0) {
return false; // Invalid - contains only emojis
}
}
return true; // Valid - no emoji-only links found
}; Add this to the start of the const updateComment = useCallback(
(commentValue: string, shouldDebounceSaveComment?: boolean) => {
raiseIsScrollLikelyLayoutTriggered();
let validatedComment = commentValue;
if (!validateEmojiLinks(commentValue)) {
// If emoji-only links found, convert [emoji](url) to "emoji url"
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
validatedComment = commentValue.replace(linkRegex, (fullMatch, anchorText, url) => {
return `${anchorText} ${url}`;
});
}
// Continue with existing emoji processing
const {startIndex, endIndex, diff} = findNewlyAddedChars(lastTextRef.current, validatedComment); This is obviously a rough attempt, we'd probably add another function to What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?You could obviously add unit tests for verifying the validation function. What alternative solutions did you explore? (Optional)In |
📣 @varun531! 📣
|
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
Edited by proposal-police: This proposal was edited at 2024-12-26 20:53:41 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Web - Compose Box - Emoji only is being accepted as an anchor text What is the root cause of that problem?the link rule used by the parser.replace function does not count for this case : What changes do you think we should make in order to solve the problem?according to the issue of the PR that caused this we want to allow emojis if combined with text but not only emojis.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?we can add a test for replace the function to verify emoji doesn't get hyperlinked and a test for containsOnlyEmojis What alternative solutions did you explore? (Optional) |
Thanks @dukenv0307! That's super helpful context. It seems like we started allowing emojis to be hyperlinked because they used to look bad (the underline intersected with the emoji), but they look fine now. I don't see any issue with allowing hyperlinks when an emoji is part of a text thread, but I can see an argument for not allowing emoji-only hyperlinks. I started a discussion in Slack (here) to see if we want to allow emoji-only hyperlinks or now. |
I confirmed with the team that we would like to continue allowing emoji-only hyperlinks. Closing! |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.78-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
Emoji only should not be accepted as an anchor text
Actual Result:
Emoji only is being accepted as an anchor text for hyperlinks
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6679568_1732833962064.AnchorEmoji.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: