Closed kavimuru closed 1 year ago
FYI: this is the original PR (reviewer look familiar? 😄): https://github.com/Expensify/expensify-common/pull/232
Hired @s77rt . @esh-g and @bernhardoj - I can't find you on Upworks, can you:
@yuwenmemon I see. But actually, I just realized that we may still need to escape it on E/App in case the text length is more than the max markup length.
@jliexpensify here is my upwork profile https://www.upwork.com/freelancers/~013e648527fa0266fd
@bernhardoj Why would that be a problem for long text? The message will be sent directly to the backend as it is which is basically the expected behavior.
@s77rt Yes, but the message is not escaped. So if we have html entities inside the long text, &
will become & again.
Ah yes but I think that goes for everything else, the behavior will be different as on long text we are not sending html but plaintext e.g. send a long text that contain *bold*
the text won't be in bold. The only reason for that difference seems due to performance.
@jliexpensify Here is my Upwork profile: https://www.upwork.com/freelancers/~0186b1d7cc69656f22
I'll update my name to match this
Yes, it won't be converted to HTML for long text, but we still need to escape it.
Assume this is a long text: long text with *markdown* & HTML entities
If we don't escape it, the text we will see become long text with *markdown* & HTML entities
.
Notice the &
become &
because we decode it inside ReportActionItemFragment
.
So the plan is: For short texts: parse the message (markdown) and encode the text For long texts: we can't parse it due to performance reasons but just encode it (assuming that encoding is not a heavy process)
Yes, correct. We won't change the parsing part, just the encoding/escaping. So, should we reopen the PR?
We still need to fix this upstream. The replace
method (in expensify-common) should not prevent double-escape. And for E/App for texts that are too long we just encode them if that's not a slow process.
Should we just remove the safeEscape
from replace
method? So,
safeEscape
in expensify-commonexpensify-common (replace
method):
- let replacedText = shouldEscapeText ? Str.safeEscape(text) : text;
+ let replacedText = shouldEscapeText ? _.escape(text) : text;
E/App
- return text.length < CONST.MAX_MARKUP_LENGTH ? parser.replace(text) : text;
+ return text.length < CONST.MAX_MARKUP_LENGTH ? parser.replace(text) : _.escape(text);
I'm expecting something like that ^
Got it 👍. I will open the PR in a few hours.
PR is up.
@s77rt We are expecting this issue to solve these issues as well.
cc: @bernhardoj
@sobitneupane I don't know how to test the notification, but the LHN part, I have tested and the upcoming PR for this issue won't fix it. There is an issue reported for the LHN issue too here https://github.com/Expensify/App/issues/15920. You can take a look at the video and notice the LHN preview able to shows
for a while, then converted to empty space. I'm guessing there is 2 decoding happen, once from the BE and once from the front-end. So, when we send
,
&nbsp;
I take a look at the PR you linked and looks like the solution to it is to remove the decoding from FE. So, I think we should decide where we should do the decoding.
@sobitneupane I'm not sure how those linked issues are related to what we are fixing here.
&
we will send &amp;
so the returned message gets decoded correctly to reflect what the user initially sent).The text fragment from the back-end is already decoded, so we send
and it should not change. There is definitely some extra decode somewhere that is decoding it to a blank space. This issue mentions HTML characters are converted in chat, so I would think we need to fix it here?
I checked and yes, the last message text shown on LHN and text fragment both decoded from backend and for LHN last message, we decode it again here.
which is actually not related to this issue. @s77rt first point explained what we are trying to fix here.
@pecanoro This issue here is about what we send to the server and not about what receive from the server. So I'm not sure what you are referring to can be fixed here. Can you please create a new issue and assign me there? I'd like to verify the performed actions and actual/expected results of the new issue to better confirm if this can handled here or in a separated issue.
Adding to @bernhardoj I have mentioned the same here https://github.com/Expensify/App/pull/15340#issuecomment-1469605794. It would be best to create a separate issue given that the root cause is not the same.
I think I understand now.
Hehe yes, I think we have a few issues and all of them are linked together. I think you can focus on your original fix and once that is merged, we can deal with whatever else is to handle so we don't undo any previous fix by mistake.
I think decoding the text is what we are doing wrong here, but I'm expecting that to be fixed in this PR https://github.com/Expensify/App/pull/15340 Either way let's wait to get this issue fixed then we can see how to move forward.
Expensify common PR is merged.
I have opened the App PR.
cc: @s77rt
Oops! I gotta create the Web-Expensify PR don't I?
@yuwenmemon No, I don't think so.
@s77rt I do, because we use ExpensiMark in that code as well. Sorry I wasn't really asking I was saying I forgot to do it! (All taken care of now though!)
Ah yes, I think this is only for Concierge?
Correctomundo!
Reviewing
label has been removed, please complete the "BugZero Checklist".
The solution for this issue has been :rocket: deployed to production :rocket: in version 1.2.89-0 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2023-04-03. :confetti_ball:
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
Regression Test Proposal
&
as a message&
I was going to close this issue since the problem was almost the same as here and got fixed already, but I am wondering if that one deserves the reporting bonus instead of this one since the other one was created before.
I personally think both issues deserve the reporting bonus - the contributors did both report valid bugs (even if they're similar), and the reporting bonus isn't large (only $250). We can also bring this up in #bug-zero if you wanted a second opinion?
Looks like there are no regressions, so creating the GH for regression test and paying everyone.
All paid, and job closed!
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:
<
or any other HTML character in the compose boxExpected Result
<
should remain the same (i.e. we don't want to convert HTML characters)Actual Result
<
becomes the < signWorkaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.2.78-0 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:
https://user-images.githubusercontent.com/43996225/221594543-a616c80e-1b39-4c57-b9b7-2dfdc2f0f3d8.mov
https://user-images.githubusercontent.com/43996225/221594593-0ce68ce7-dc75-49b4-b19a-118429c75a92.mp4
Expensify/Expensify Issue URL: Issue reported by: @esh-g Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1677316598380029
View all open jobs on GitHub
Upwork Automation - Do Not Edit