You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Formatting of email responses in NewDot isn't pretty #8088
@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?
Web
iOS
Android
Desktop App
Mobile Web
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
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:
Email request is either using VML/XML namespaces or is from an unknown provider, relying on mailgun's stripped HTML content
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
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:
We can also strip out whitespace after stripped HTML but that also leads to some unintended changes in other email providers
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
Could you elaborate on those unintended changes?
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.
Maybe we can trim any whitespaces before and after the stripped HTML?
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.
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)
" <div class=\"WordSection1\"> <p class=\"MsoNormal\">Hi SomeName, </p><p></p> <p class=\"MsoNormal\"></p><p> </p> <p class=\"MsoNormal\">Will tomorrow at 34 est. work?</p><p></p> <p class=\"MsoNormal\"></p><p> </p> <p class=\"MsoNormal\">Thanks, Test</p><p></p> <p class=\"MsoNormal\"></p><p> </p> </div>xxxxxx xxxxxxxx xx xxx: xxxx x-xxxx xxx xxxxxxxxxx xx xxxxxxxxxxxxx xx xxxxxxxxxxxx xxxxx x.x. xxx, xx xxx xxxxxxx xxxxxxx xx xx xxxxxxxxx xx xxxxxxx x xxx..."
This case is NOT rendered as HTML because of this exception in handling it, so it works in both cases.
and 3. There are other html tags than <br />, so we render these cases using the react-native-render-html library.
I think it makes sense to add the white-space: pre when we are rendering html messages typed by the user in our App because that makes them render as close as possible to what the user initially typed (preserving spacing). The problem appears when the message came from an email. The email client has a different way of rendering the HTML of the message, they use white-space: normal and to preserve spacing.
We could try one of the following fixes:
Flag the messages that came from the email intake, don't force white-space: pre for the flagged messages
Check if the message contains a , if it does, don't force white-space: pre
Do heavier processing of the email in the backend to avoid the amount of weird structured html in them, but that sounds like an endless amount of work.
I did some more testing today and found out that outlook likes to add a bunch of \n in the email's html. The \n with whitespace: pre makes a lot of empty lines appear.
The proposed solution of avoid using whitespace: pre for message comings from emails handles well this case, so I'm sticking with that.
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!
Activity
MelvinBot commentedon Mar 11, 2022
Triggered auto assignment to @MariaHCD (
Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.MariaHCD commentedon Mar 14, 2022
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?
zsgreenwald commentedon Mar 14, 2022
On it!
MariaHCD commentedon Mar 15, 2022
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?
thienlnam commentedon Mar 15, 2022
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
MariaHCD commentedon Mar 16, 2022
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?
thienlnam commentedon Mar 16, 2022
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
MariaHCD commentedon Mar 21, 2022
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.
36 remaining items
aldo-expensify commentedon Jun 4, 2022
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)
aldo-expensify commentedon Jun 8, 2022
From what I can see, we have the following cases:
white-space: pre"0 spaces<br /> 1 spaces<br /> 2 spaces<br /> 3 spaces<br /> 4 spaces""0 spaces<br /> 1 spaces<br /> 2 spaces<br /> 3 spaces<br /> 4 spaces<br /> <pre>Test</pre>"I think it makes sense to add the
white-space: prewhen we are rendering html messages typed by the user in our App because that makes them render as close as possible to what the user initially typed (preserving spacing). The problem appears when the message came from an email. The email client has a different way of rendering the HTML of the message, they usewhite-space: normaland to preserve spacing.We could try one of the following fixes:
white-space: prefor the flagged messages , if it does, don't forcewhite-space: preReplace. This didn't work: Remove whitespace: pre because of extra empty lines bug #9195 (comment) by normal space and keep forcingwhite-space: prealdo-expensify commentedon Jun 8, 2022
Just mentioning that if you edit the message that came from the email reply, it "breaks" like this:
The result is the same with and without
white-space:prealdo-expensify commentedon Jun 20, 2022
I did some more testing today and found out that outlook likes to add a bunch of
\nin the email's html. The\nwithwhitespace: premakes a lot of empty lines appear.The proposed solution of avoid using
whitespace: prefor message comings from emails handles well this case, so I'm sticking with that.I updated the PR's descriptions and made them ready for review.
melvin-bot commentedon Jul 14, 2022
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!