PHP Classes

HTML Sanitizer: Remove unsafe tags and attributes from HTML code

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 67%Total: 3,405 This week: 1All time: 1,006 This week: 560Up
Version License PHP version Categories
htmlsanitizer 1.3GNU General Publi...5.2HTML, Security
Description 

Author

This class can be used to remove unsafe tags and attributes from HTML code.

It takes a string with HTML code and strips all the tags that do not make part of a list of safe tags. That list of safe tags is defined as a private class variable. There are some functions to allow usually unsafe tags like script, style, object, embed, etc..

The class can also remove unsafe tag attributes, such as those that define Javascript code to handle events.

The links href attributes also gets special treatment to remove URLs that trigger Javascript code execution and line breaks.

Picture of Frédéric Minne
Name: Frédéric Minne <contact>
Classes: 2 packages by
Country: Belgium Belgium
Age: 45
All time rank: 5611 in Belgium Belgium
Week rank: 416 Up3 in Belgium Belgium Down

Details

HTML Sanitizer

Simple lightweight HTML sanitizer class for PHP

Copyright notice

(see COPYING for more details)


Copyright (c) 2005-2013 Frederic Minne <zefredz@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU LESSER General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  Files folder image Files  
File Role Description
Accessible without login Plain text file COPYING Lic. GNU LGPL
Accessible without login Plain text file helpers.lib.php Aux. Auxiliary script
Plain text file HTML_Sanitizer.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file sample.php Example Example

 Version Control Unique User Downloads Download Rankings  
 100%
Total:3,405
This week:1
All time:1,006
This week:560Up
 User Ratings  
 
 All time
Utility:86%StarStarStarStarStar
Consistency:86%StarStarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:67%StarStarStarStar
Rank:457