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

Don't strip tags from user-generated content #231

Open
boonebgorges opened this issue Jan 19, 2023 · 0 comments
Open

Don't strip tags from user-generated content #231

boonebgorges opened this issue Jan 19, 2023 · 0 comments

Comments

@boonebgorges
Copy link
Owner

Related: #226, #220

When the plugin was first written, all BP emails were in plain text. So it made sense that we ran {{usermessage}} through strip_tags().

That was many years ago. Now, I'm guessing that the overwhelming majority of BP sites use BP's HTML emails. This means that we could begin allowing at least some HTML in emails.

A few considerations:

  • Emails are still sometimes sent as plain-text. The installation could be set up in such a way to force plain-text, or there could be a user preference to send plain-text emails only. In any case, we always send a plain-text version of the entire message in case the email client is configured not to parse HTML. So we still need the capacity to strip tags.
  • It's possible that tags in {{usermessage}} could be unbalanced, either due to excerpting or user error. We need to prevent against this.
  • We'll almost certainly want to impose pretty strict limits on the allowed tags. a, text formatting tags like em, list tags, img - probably not much more than that.
  • Rendering inline images poses a bunch of problems. If the src is not publicly accessible (due to .htaccess, blog_public, or some other restriction), the images won't render. Our best bet here may be to render img tags by default, but to have robust filters in place to allow third-party developers to disable or modify the way that img tags are included. See https://github.com/openlab-at-city-tech/openlab/blob/cfbba887d755abcb50e963743c81d50ddc2a36e2/wp-content/plugins/openlab-email-embedded-media/openlab-email-embedded-media.php for a specific implementation that demonstrates an approach.
  • Another image is problem is that large images can break layout. We would likely want to intercept inline img tags and impose strict limits on the width parameter, to ensure that it works reasonably well across devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant