Skip to content
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

Some emails are showing just plain html instead of text #2099

Closed
sosnovsky opened this issue Feb 10, 2023 · 14 comments · Fixed by #2291
Closed

Some emails are showing just plain html instead of text #2099

sosnovsky opened this issue Feb 10, 2023 · 14 comments · Fixed by #2291
Assignees

Comments

@sosnovsky
Copy link
Collaborator

sosnovsky commented Feb 10, 2023

Currently app should strip html code and render just plain text for html emails. But it fails for some emails and showing just plain html, which makes it quite difficult to read message content.

@sosnovsky sosnovsky added this to the 1.2.5: Maintenance milestone Feb 10, 2023
@tomholub
Copy link
Collaborator

It's possible this problem only occurs when sending html email from browser extension in particular (only supported on Firefox, like this)

image

Because the format is not entirely correct. Maybe it works ok for HTML emails from other clients? (can check from flowcrypt.compatibility account later). If that is true, then the problem is only in recognizing it as a HTML message and treating it as such. We already had ability to parse and render HTML emails as text, to my knowledge.

@tomholub
Copy link
Collaborator

In either case, we already support rendering regular HTML emails as text, at the least, so we do have the functionality available to do this relatively easily.

@sosnovsky
Copy link
Collaborator Author

It happens not for FlowCrypt emails, but for some usual messages - for example, html isn't rendered for emails from reddit and for some email confirmation messages. I noticed that they start with such doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-strict.dtd">

<html xmIns="http://www.w3.org/1999/xhtm|"
...

While other html messages work well - showing plain text extracted from html.

@sosnovsky sosnovsky changed the title Add support for html emails Some emails are showing just plain html instead of text Feb 10, 2023
@tomholub
Copy link
Collaborator

Ah. That must have been broken relatively recently.

@tomholub
Copy link
Collaborator

tomholub commented Feb 10, 2023

Ah. That must have been broken relatively recently.

Or, it never worked for some types of html emails. Please if you could, try adding a sample to flowcrypt.compatibility email and mention the subject here, to later have it ready as a sample.

@sosnovsky
Copy link
Collaborator Author

I think it was broken initially, as we didn't have any changes for html rendering recently.
Will try to create sample email which fails to render and add it to flowcrypt.compatibility account

@sosnovsky
Copy link
Collaborator Author

@ioanmo226 I sent you example message which fails to render correctly on iOS

@ioanmo226
Copy link
Collaborator

Hmm.. IOS app renders exactly like browser extension.
Did I miss something?
image

@sosnovsky
Copy link
Collaborator Author

Example message is in ios-2099.eml, I haven't found way to directly send html of original message

@ioanmo226
Copy link
Collaborator

Aha, I see. Sorry for confusion

@sosnovsky
Copy link
Collaborator Author

Yeah, probably my email text wasn't very clear :)

@ioanmo226
Copy link
Collaborator

@sosnovsky Upon checking, I found that the NSAttributedString initializer doesn't recognize the xmlns HTML (compatible with Microsoft Office email). As a result, the aforementioned HTML is treated like standard text and is thus rendered as such.

I can suggest 2 potential solutions for this issue:

  1. Use an XML/HTML parser library, such as Fuzi or SwiftSoup.
  2. Opt for a webview instead of TextView.

Which option would you prefer?

@sosnovsky
Copy link
Collaborator Author

Use an XML/HTML parser library, such as Fuzi or SwiftSoup.

Looks like these libraries are not actively developed, so it'll be risky to be dependent on them for rendering messages.

Opt for a webview instead of TextView.

We'll probably start using webview in the future, to be able to render html emails, not only plain text, but it'll be a bigger feature, here I thought it will be just a small fix.

Maybe we can just update doctype or replace xmlns to make it work with NSAttributedString?

@ioanmo226
Copy link
Collaborator

I see.
Let me try with this method.

Maybe we can just update doctype or replace xmlns to make it work with NSAttributedString?

sosnovsky pushed a commit that referenced this issue Jul 24, 2023
* fix: email showing as plain html issue

* fix: decrypt issue

* fix: text

* fix: ui test

* fix: pr reviews

* fix: pr reviews

* fix: email showing as platin text issue

* simplify

* fix: pr review

* fix: pr reviews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants