Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

[$500] Do not allow emojis to be formatted (ie italics) #14676

Open kavimuru opened 1 year ago

kavimuru commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to android app
  2. Go to any chat
  3. Try to make emoji in italic form:-Type in : insertemoji For example:⁦:100:, _⁦:purpleheart: , _⁦:partyingface: ,
  4. Notice that the top right part of the emoji cuts off. Few Example: the :100:, :purple_heart:, :partying_face: emoji has its top right section cut , (It happens on android only latest)

Expected Result:

Users should not be able to format emojis, lets keep them with normal style (no bold, italics, strikethrough etc)

Actual Result:

Users can make emoji italic which leads to the emojis to cut off a few parts of the emoji (for some emojis)

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Version Number: 1.2.62-1 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:

Expensify/Expensify Issue URL: Issue reported by: @priya-zha Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1675094271396099

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017d08e0c09284d31f
  • Upwork Job ID: 1620563000799895552
  • Last Price Increase: 2024-08-08
  • Automatic offers:
    • eh2077 | Reviewer | 0
    • wildan-m | Contributor | 0
Issue OwnerCurrent Issue Owner: @mallenexpensify / @mallenexpensify
MelvinBot commented 1 year ago

Current assignee @aimane-chnaif is eligible for the Internal assigner, not assigning anyone new.

tienifr commented 1 year ago

@tienifr we already discussed. that's why we suggest to fix this in render level

Sure, I misunderstood what you mean by render level. In this case we can just apply the sequence of regex mentioned previously in here to the rendering.

Updated Proposal

Please re-state the problem that we are trying to solve in this issue.

Emoji has italic style if put in _ _ in markdown.

What is the root cause of that problem?

The emoji inside <em>/<i> tag in html has italic style. Same for bold.

What changes do you think we should make in order to solve the problem?

As mentioned by @aimane-chnaif above, when rendering the html, we can exclude the emoji from the em and similar tags. We can do that adding the following function to process the html (it's basically the same as the steps mentioned earlier in here, just applying to the rendering instead of markdown-to-html):

const excludeEmojisFromItalicAndBoldTags = (text) => {
    return text.replace(/<(em|i|b|strong)(?:"[^"]*"|'[^']*'|[^'">])*>([\s\S]*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi, (match, g1) => {
        const textWithEmojiExcluded = match.replace(/(([\p{Extended_Pictographic}](\u200D[\p{Extended_Pictographic}]|[\u{1F3FB}-\u{1F3FF}]|[\u{E0020}-\u{E007F}]|\uFE0F|\u20E3)*|[\u{1F1E6}-\u{1F1FF}]{2}|[#*0-9]\uFE0F?\u20E3)+)/gu, `</${g1}>$1<${g1}>`);
        const textWithEmptyTagRemoved = textWithEmojiExcluded.replace(new RegExp(`<${g1}></${g1}>`, 'g'), '');
        return textWithEmptyTagRemoved;
    });
}

this will be called with htmlContent as the param right before this line here https://github.com/Expensify/App/blob/79e8dd706f5760f398eaa1b94e2e2be97805fd6a/src/pages/home/report/ReportActionItemFragment.js#L112

const htmlContent = excludeEmojisFromItalicAndBoldTags(html + editedTag);

This will replace all emoji group inside the <em>, </em> by '</em>$1<em>', which will achieve the desired behavior.

We further refine this by removing redundant <em></em> that doesn't have any content inside. This can happen if an emoji happens to be right next to the leading and trailing <em>.

What alternative solutions did you explore? (Optional)

Another way is instead of the regex above to handle the emojis, we can have a regex to replace all non-emoji character group with <em>$1</em> (the <em> or </em> will be omitted if the group is next to the start or end of the tag)

bernhardoj commented 1 year ago

There is an issue that expects (only) emojis inside bold and italic should have larger size. But based on this confirmation, it shouldn't. But (again), in this issue, we are trying to take out the emoji from the italic/bold tag, which technically makes the emojis not inside bold/italic anymore. So, I have updated my proposal with a very little bit changes in case we want to show larger emojis inside bold/italic. If not, then I think we can close this issue.

anmurali commented 1 year ago

Proposals still being evaluated

aimane-chnaif commented 1 year ago

started public discussion here

aimane-chnaif commented 1 year ago

Still discussing on slack. Not many inputs so far.

flodnv commented 1 year ago

I asked for more voices on one of our internal Slack channels

flodnv commented 1 year ago

Callstack is going to take a look at this, although Rocio suggested that https://github.com/Expensify/App/pull/15611 might solve this issue.

flodnv commented 1 year ago

Let's HOLD on that PR to see if it fixes it.

flodnv commented 1 year ago

Still HOLDing, that PR is in progress.

flodnv commented 1 year ago

Same.

flodnv commented 1 year ago

That PR is now on HOLD with a bunch of conflicts 😂 moving this to Monthly...

flodnv commented 1 year ago

Still on HOLD, now held by https://github.com/facebook/hermes/pull/968

priya-zha commented 1 year ago

Hi @flodnv. Wanted to know if this issue here is same or not?

flodnv commented 1 year ago

I don't know, sorry

mountiny commented 1 year ago

Updating the issue body and title here. In this discussion we have agreed to not allow the emojis to be italics.

flodnv commented 1 year ago

This is still waiting on https://github.com/facebook/hermes/pull/968, which had some progress in the past month.

anmurali commented 1 year ago

https://github.com/facebook/hermes/pull/968 is still WIP

flodnv commented 1 year ago

Wow, it was merged!! 😂 What now?! Do you know how these PRs end up in RN releases @mountiny ?

mountiny commented 1 year ago

I believe there should be new 0.73 release coming up soon (October hopefully) cc @fabioh8010 do you have some better ETA?

fabioh8010 commented 1 year ago

Hi @mountiny , the target date for RN 0.73 is 23 October (more info here). And according to Meta's team, this Hermes improvement is expected to be available on RN 0.73 as well.

But please have in mind that ETA will likely be 23 October + time to update E/App to latest RN version.

mountiny commented 1 year ago

Cool thanks!

flodnv commented 1 year ago

Still waiting for RN 0.73

flodnv commented 12 months ago

Same.

fabioh8010 commented 12 months ago

We also can watch for this PR which is updating the app to 0.73 -> https://github.com/Expensify/App/pull/31558

flodnv commented 11 months ago

Seems like we're almost there 🙏

anmurali commented 9 months ago

https://github.com/Expensify/App/pull/31558 is deployed to production. @flodnv @fabioh8010 - what is the next step here?

flodnv commented 9 months ago

The problem still exists, so it needs to be fixed (or, we can close this issue as won't fix)

aimane-chnaif commented 9 months ago

I think this should be fixed for consistency. Also reporting from https://github.com/Expensify/App/pull/34292#issuecomment-1906078856

flodnv commented 9 months ago

Still not convinced this is a ""bug"". Look at GH:

image

Seen in https://github.com/Expensify/App/pull/35552

I think this should be fixed for consistency.

Consistency with what?

aimane-chnaif commented 9 months ago

Inconsistency meaning: This is android only bug. Also reported in https://github.com/Expensify/App/pull/34292#issuecomment-1906078856. This doesn't happen on all other platforms.

flodnv commented 9 months ago

Hm, I see the bug on Desktop and web (Chrome, MacOS). Are you saying it does not exist on iPhone?

aimane-chnaif commented 9 months ago

Ah this happen on web platforms as well? I will retest on all platforms

flodnv commented 9 months ago

Thanks, I think all that's left to test is iPhone? And maybe Android mWeb and iPhone mWeb

aimane-chnaif commented 9 months ago
Screenshot 2024-02-09 at 3 55 09 PM Screenshot 2024-02-09 at 3 55 20 PM Screenshot 2024-02-09 at 3 57 14 PM
aimane-chnaif commented 9 months ago

ok so only iOS emoji is not italic, while all other platforms are italic

flodnv commented 9 months ago

Alright then, I can kind of buy the consistency argument 👍

anmurali commented 9 months ago

Adding in BZ backup when I am OOO

melvin-bot[bot] commented 9 months ago

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

stitesExpensify commented 8 months ago

Wrong button :ohnothing:

I'm going to take this over as the internal engineer. We should hold on this until this is merged because we're adding a new <emoji> tag that will change the solution here.

I also wanted to mention that we are adding a requirement here to add a unit test. We have gone back and forth on whether emojis can be for formatted or not a few times, and we want to lock down that emojis should never be formatted.

melvin-bot[bot] commented 7 months ago

Upwork job price has been updated to $500

mallenexpensify commented 7 months ago

Off hold! @stitesExpensify , do you still want this to be a Monthly? Added to #vip-vsb because it doesn't have to do with money. This should be polish

stitesExpensify commented 7 months ago

We can switch it back to daily. I'm going to add external and help wanted as well

melvin-bot[bot] commented 7 months ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (External)

stitesExpensify commented 7 months ago

I'm not sure why @eh2077 was added, @aimane-chnaif is already the c+ here right?

eh2077 commented 7 months ago

@stitesExpensify I'm not sure if this is because @aimane-chnaif is OOO as they mentioned here

stitesExpensify commented 7 months ago

Ahh yep that's definitely it! Thanks for clarifying for me :)

aimane-chnaif commented 7 months ago

right. I am currently OOO and temporarily removed from github team.

eh2077 commented 7 months ago

Wrong button :ohnothing:

I'm going to take this over as the internal engineer. We should hold on this until this is merged because we're adding a new <emoji> tag that will change the solution here.

I also wanted to mention that we are adding a requirement here to add a unit test. We have gone back and forth on whether emojis can be for formatted or not a few times, and we want to lock down that emojis should never be formatted.

@tienifr @bernhardoj Would you like to update your proposals based on this https://github.com/Expensify/App/issues/14676#issuecomment-1967604879 ?

bernhardoj commented 7 months ago

Updated my proposal, but it's only for sent message and not for live markdown preview.