-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Formatting of email responses in NewDot isn't pretty #8088
Comments
Triggered auto assignment to @MariaHCD ( |
I think this could be an issue on the backend when parsing the response (and thus, possibly not something an external contributor could work on) @zsgreenwald Would you mind DM'ing me more details (eg. the user's email) so I can investigate further via the logs and possibly on Mailgun as well? |
On it! |
Looks like we ran into something similar here: https://github.com/Expensify/Expensify/issues/142335 Looking at the logs for the user that @zsgreenwald sent over via DM, looks like we defaulted to mailgun's stripped HTML content instead of parsing it ourselves:
cc: @thienlnam Not sure if we can do anything here? |
Yeah, not much we can do here unless we try to strip it ourselves which leads to endless things we'd have to account for. Since mailgun email stripping has been unreliable we can look into using another library for this except we'd need to test multiple platforms to make sure it works and isn't stripping out text content. We can also strip out whitespace after stripped HTML but that also leads to some unintended changes in other email providers |
Thanks, @thienlnam! So it sounds like: Option 1: Strip the content ourselves (which would be tricky due to the endless number of mail providers that we'd have to account for) Option 2: Investigate usage of another library (which would entail lots of tests across multiple platforms to ensure the text content isn't being stripped) Option 3:
Could you elaborate on those unintended changes? Maybe we can trim any whitespaces before and after the stripped HTML? |
Yup those options are correct, I think option 2 would actually be worthwhile to do
It's been a while so I might not be remembering correctly, but IIRC stripping whitespace messed up the email formatting inside the email and made (yahoo?) emails look especially bad. I think we had this enabled at one point but decided to revert it.
Yeah this could help a bit, though it looks like in the linked issue the spacing is bad between text and before/after the text too and so it would still look bad |
Great, thanks, @thienlnam! So moving forward, sounds like the best option would be to investigate usage of another library and this is something that can be handled internally as it is a backend change. |
Triggered auto assignment to @NicMendonca ( |
This issue was not reported by a contributor. |
I worked in this in the past in this PR. I added a function to trim the html, but it missed to consider cases where there are spaces using |
This issue has not been updated in over 15 days. @aldo-expensify eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
@aldo-expensify @MariaHCD what's the latest with this? I'm still noticing some heavily spaced formatting on incoming messages from email. Some screenshots below: |
Hey @zsgreenwald , I made a PR, but it seems like it didn't work in this case. I'll have a look and see what it may be |
Ah this has been a PITA in the past, we've had a lot of trouble parsing / cleaning specially formatted emails from outlook which I believe this is - for these types of emails we delegate the html stripping to mailgun. In the past, we've just stripped all line breaks to solve this problem but it removed any line breaks intended within the email which also didn't look great @aldo-expensify You could try removing all break tags before text content starts, but there's a lot of email formatting overhead that you would have to figure out. |
It is indeed a PITA, but I think there is room from improvement. I'm testing locally with a message with the following html (this is what we end up with after our API processes the email):
The problem seems to be that whitespaces before the text "Hi Zach" are getting wrapped in divs in the front end. These are the white lines we see. become these divs: I think this is a problem to fix in the front end, but I'm not sure where the html gets transformed yet. On the backend, we have some code that tries to trim the html by removing tags that don't have text content and that don't have text content after or before them. Applying the same logic, I can remove the TEXT nodes that are just blank spaces in the borders of the email that are getting converted to divs (see this draft PR). This works, but only for the white lines that are added at the top and bottom... but I think there are still some white lines added in between because of the spaces being wrapped in divs. Result: |
Changing this prop dangerouslyDisableWhitespaceCollapsing to |
@parasharrajat this PR: #6975 changed dangerouslyDisableWhitespaceCollapsing to |
We are removing that flag in another issue. I will add the PR link as soon as I find it. |
That PR is #9025 |
The solution in that PR seems to cause the exact same problem for this case: Screen.Recording.2022-05-17.at.4.39.25.PM.movI don't think we should be changing how the whitespace works when rendering html outside a |
@aldo-expensify I noticed this PR merged. I'm waiting on some email responses to come in, but should that merge fix the issue? |
I tested locally that PR and it seems to cause the same problem. |
I investigate this a bit more today and I know better now when it happens, but I haven't been able to come up with a solution. I have a clearer way to reproduce it here: #9195 (comment) |
From what I can see, we have the following cases:
I think it makes sense to add the We could try one of the following fixes:
|
I did some more testing today and found out that outlook likes to add a bunch of The proposed solution of avoid using I updated the PR's descriptions and made them ready for review. |
This issue has not been updated in over 15 days. @aldo-expensify eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
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:
@greeny was sending messages back/forth to a business partner
Expected Result:
When the partner replied via email that the formatting would like nice and there wouldn't be extra line breaks
Actual Result:
Formatting is a bit janky, inc. extra line breaks
Workaround:
unknown
Platform:
Where is this issue occurring?
Version Number: 1.1.41-3

Reproducible in staging?: need repro
Reproducible in production?: Y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
Issue reported by: @mallenexpensify
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1646931708047189
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: