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

  • Home
  • SEARCH
  • 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 6472921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:24:12+00:00 2026-05-25T06:24:12+00:00

I have added a simple wysiwyg editor in my website. (it only allows B

  • 0

I have added a simple wysiwyg editor in my website. (it only allows B / I / U – no more)
I currently store all content as html in my database – but it’s simple to add <a onclick='...'> or other malicious code)

What is the best way in PHP to parse this input safely?
How to implement <b></b>, <i></i> and so on as whitelist and encode everything else?

  • 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-05-25T06:24:12+00:00Added an answer on May 25, 2026 at 6:24 am

    HTMLPurifier

    I’m just going to throw this one out there and probably get the inevitable lashing. I would not use strip_tags to secure your WYSIWYG form… ever (Unless you want to piss off your users).

    It won’t secure your form, and you may be killing your user’s experience.

    Chris Shiftlett in his blog post wrote an excellent paragraph

    I detest commenting on blogs where my comment is passed through something like strip_tags(), effectively mangling what I’m trying to say. It reminds me of using an IM client that tries to identify smilies and replace them with images, often making responses difficult to decipher.

    Another Reason

    Someone else in another answer also wrote this which I like:

      $str = "10 appels is <than 12 apples";
      var_dump(strip_tags($str));
    

    The output I get is:

    string '10 appels is ' (length=13)
    

    I personally would not use anything other than HTMLPurifier

    HTMLPurifier

    HTMLPurifier

    Try a demo here: http://htmlpurifier.org/demo.php

    And look at this similar question

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

Sidebar

Related Questions

I have a simple HTML table which is bound using knockoutJS. However, I've added
Here is my .classpath file, after I have added two more external jars (org.restlet.ext.simple.jar
I have coded my calculator in simple mode, I have added a button for
I have a simple ASP.NET 3.5 SP1 Web Forms app... I've added the System.Web.Routing
I have added a simple .gif file into Resources folder in my project. Now
Hi i have created a simple menu in Flash. I have added the following
I have added a Bundled Product in Magento programmatically, using all the options /
I am using nicEdit editor and I have added my own custom image resizing
I have added a simple .js file to my page that has some pretty
I have added a simple Cedit control to my dialog and have an OnEnChangeEdit

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.