-
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] Chat-On adding spade symbol, link is changed to text. #44835
Comments
Triggered auto assignment to @twisterdotcom ( |
We think this issue might be related to the #vip-vsb |
Okay... this is super niche. I'm going to make it |
Job added to Upwork: https://www.upwork.com/jobs/~01a1dba0f8a6c08731 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rayane-djouah ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Adding spade symbol to the link text doesn't convert it to link. What is the root cause of that problem?The spade symbol is an emoji, while the others are not emoji. Based on the link markdown replacement logic, we don't allow emojis to be inside the link text. It's to fix this issue where the link underline partly behind the emoji character which doesn't look good, so we disable emoji inside link text. What changes do you think we should make in order to solve the problem?Allow the emoji back to be inside the link text by removing the emoji check condition here. This is how it looks when an emoji is inside the link text. GitHub also allows emoji to be inside link text |
ProposalPlease re-state the problem that we are trying to solve in this issue.On adding spade symbol, link is changed to text. What is the root cause of that problem?In https://github.com/Expensify/expensify-common/blob/2610f15e7fb8d98d19b3841146c693df7be0a5c9/lib/ExpensiMark.ts#L252, we don't match link text that has any emojis. This was an oversight from this PR Expensify/expensify-common#536, we should not allow link text with only emojis because it will not look good (described in the issue description), but if emojis are with other texts, we should still allow it. That will be the behavior consistent with Slack. What changes do you think we should make in order to solve the problem?Put the method containsOnlyEmojis inside In https://github.com/Expensify/expensify-common/blob/2610f15e7fb8d98d19b3841146c693df7be0a5c9/lib/ExpensiMark.ts#L252, remove What alternative solutions did you explore? (Optional)In addition to that that check, we could check that length of |
ProposalPlease re-state the problem that we are trying to solve in this issue.We are trying to resolve the issue where special characters, such as the spade symbol (♤), in comments are being displayed as plain text instead of clickable links on Expensify's staging site. What is the root cause of that problem?The root cause of the problem is that the special characters are not being properly encoded and sanitized, leading to issues in rendering them correctly in HTML comments. This results in the characters being displayed as plain text instead of clickable links. What changes do you think we should make in order to solve the problem?To solve this issue, we utilized the In const sanitizedHtml = sanitizeHTML(html);
const decodedHtml = he.decode(sanitizedHtml);
const commentHtml = source === 'email' ? `<email-comment>${decodedHtml}</email-comment>` : `<comment>${decodedHtml}</comment>`;
return <RenderHTML html={commentHtml} />; In const [draft, setDraft] = useState(() => {
if (draftMessage) {
emojisPresentBefore.current = EmojiUtils.extractEmojis(draftMessage);
}
return he.decode(draftMessage);
});
const updateDraft = useCallback(
(newDraftInput: string) => {
const { text: newDraft, emojis, cursorPosition } = EmojiUtils.replaceAndExtractEmojis(newDraftInput, preferredSkinTone, preferredLocale);
if (emojis?.length > 0) {
const newEmojis = EmojiUtils.getAddedEmojis(emojis, emojisPresentBefore.current);
if (newEmojis?.length > 0) {
insertedEmojis.current = [...insertedEmojis.current, ...newEmojis];
debouncedUpdateFrequentlyUsedEmojis();
}
}
emojisPresentBefore.current = emojis;
const safeDraft = sanitizeHTML(he.encode(newDraft));
setDraft(he.decode(safeDraft));
}
); In import { JSDOM } from 'jsdom';
import DOMPurify from 'dompurify';
import he from 'he';
// Initialize DOMPurify with JSDOM
const window = new JSDOM('').window;
const purify = DOMPurify(window);
export default function sanitizeHTML(input: string): string {
// Encode HTML entities
const encodedHTML = he.encode(input);
// Sanitize the encoded HTML
const sanitizedHTML = purify.sanitize(encodedHTML, {
USE_PROFILES: { html: true }
});
// Decode HTML entities
const decodedHTML = he.decode(sanitizedHTML);
return decodedHTML;
} Why we used this solution:
By using these libraries, we ensure that special characters are correctly handled and rendered, fixing the issue of them being displayed as plain text instead of clickable links. What alternative solutions did you explore? (Optional)Alternative solutions considered included manually encoding and sanitizing the HTML content. However, this approach was prone to errors and did not provide the comprehensive security and reliability offered by the Video DemonstrationTo visually illustrate the problem and the solution implemented, please watch the following screencast. In this video, we demonstrate how special characters in comments on Expensify's staging site were displaying incorrectly and how we used the Recording.2024-07-07.163622.mp4 |
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
Proposal |
Reviewing proposals |
@bernhardoj's proposal LGTM It seems that the "Emoji anchor text with hyperlink doesn't look right" bug is old and has been fixed. Therefore, we don't need the condition that excludes text with emojis from being the anchor text for links or emails. Here is the result when removing the condition: Screen.Recording.2024-07-09.at.11.43.47.PM.movWe need to revert Expensify/expensify-common#536 and Expensify/expensify-common#583 in expensify-common and update the version in App 🎀👀🎀 C+ reviewed |
Triggered auto assignment to @francoisl, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@rayane-djouah I think it still doesn't look good which is why we fixed it earlier in #44835 (comment)
Also it's inconsistent with Slack, in Slack, single-emoji will not be accepted as anchor text. As you can see in the screenshot, emoji-only (the one above) in Slack will not be accepted as anchor text. Meanwhile emoji-with-text (the one below) will be accepted. My proposal will make it consistent with Slack. Looking forward to hear what @francoisl thinks what should be expected here |
The original argument that it doesn't look good when there is an emoji in a link is subjective, and so different people will naturally have different opinions on whether they should be accepted or not. I believe we try to stay as close as possible to "standard" markdown when possible for our parser, and from a quick look at this RFC, which points to this site for the syntax, I don't see anything mentioned about restricting specific characters or emojis in links. Let's go with @bernhardoj's proposal 👍 |
📣 @rayane-djouah 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
expensi-common PR is here cc: @rayane-djouah |
App PR is ready cc: @rayane-djouah |
@francoisl - a fix for this issue has already landed in the app via #45556 that updated the version of We need to directly QA test this on that PR. How can we inform Applause QA team about this? QA Steps:
I've tested that it's working well on staging: #45310 (comment) |
Hm in that case I think we can just close this and issue payments, what do you think @twisterdotcom? |
We can close yes. Given the work done, I'm okay with still paying out, even though we'll need to just do away with it - but are you @bernhardoj and @rayane-djouah okay with just $125 given this isn't code we'll end up using and it didn't require lots of testing? |
I think we are still eligible for full payment. The App PR is just updating the #45556 updates the |
I agree with @bernhardoj, Most of the work was done in the I think #45556 updated the version without following a proper process for issues tracking, and this wasn't the only issue affected, see for example: #37357 (comment) and #44032 (comment) |
Ah okay great, if this is the central issue for payments for all of them, then cool. I agree. Let's go with the full amount of $250 each. Payment Summary coming. |
Payment Summary:
|
Requested in ND. |
$250 approved for @bernhardoj |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.4
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team
Action Performed:
Expected Result:
On adding spade symbol, link must not be changed to text.
Actual Result:
On adding spade symbol, link is changed to text.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Bug6532762_1720075009162.az_recorder_20240704_083446_compress_1.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @rayane-djouahThe text was updated successfully, but these errors were encountered: