Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8779921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:55:03+00:00 2026-06-13T19:55:03+00:00

I have an application that needs to display foreign HTML data (e.g. HTML-encoded email

  • 0

I have an application that needs to display foreign HTML data (e.g. HTML-encoded email texts, though not only) safely – i.e., remove XSS attempts and other nasty stuff. But still be able to display HTML as it should look like. Solutions considered so far aren’t ideal:

  1. Clean HTML with something like HTMLPurifier. Works fine, but once email size goes over 100K it becomes very slow – tens of seconds per email. I suspect any secure enough parser would be as slow in PHP – some emails are really bad HTML, I’ve seen some that generate 150K HTML for one page of text.
  2. Display HTML in an iframe – here the problem is that iframe needs then to be in another origin to be safe from XSS AFAIK, and this would require different domain for the same app. Setting up application with two domains is much more work and may be very hard in some setups (such as hosting that gives only one domain name).

Any other solutions that can achieve this result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:55:04+00:00Added an answer on June 13, 2026 at 7:55 pm

    From my understanding, I don’t believe so.

    The trouble is that you can only safely remove HTML tags if you understand its structure, and ‘understanding its structure’ is exactly what parsing is. Even if you find a different way to analyse the structure of HTML and don’t call it parsing, that’s what you’re doing, and it’s bound to be some form of slow (or unsafe).

    What you could do is play around with a few preliminary filters (e.g. strip_tags, which is generally a good prelim’ (if certainly nothing else)) to give the parser less work to do, but whether that’s viable depends on the size of your tag whitelist – a small whitelist will probably yield better benchmark results, since a large chunk of HTML would be filtered out by strip_tags before the parser got to it.

    Additionally, different parsers work in different ways, and the sort of HTML you deal with frequently may be best suited to one sort of parser over another – HTML Purifier itself even has different parsers at its disposal that you can switch between to see if that results in a better benchmark for you (though I suspect the differences are negligible).

    Whether such juggling works for your usecases is something you’ll probably have to benchmark yourself, though.

    Word of caution: If you decide to pursue it, know I wouldn’t go with the iframe approach. If you don’t filter HTML, you also allow forms, and it becomes (IMO) trivial in combination with scripts and CSS to set up extremely convincing phishing, e.g. using tricks such as “this e-mail is password protected, to proceed, please enter your password“.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ExtJS application that needs to display an html document within a
I have a Silverlight application that needs to display data in both English (feet,
I have an application that needs to display a grid of data consisting mostly
I have news application that needs to download data from the url and display
I have a Java application that needs to display large amounts of data (on
I have a Rails 3 application that needs to display images from another application.
We have a GWT application that needs to display various holidays. Is there a
I have an application that needs to display a series of graphs (using Core
We have a winform application that needs to display some results calculated on the
I have a master page that needs to display some data from my database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.