Login   Register  
PHP Classes
elePHPant
Icontem

Secure HTML parser and filter

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

  Author  
Picture of Manuel Lemos
Name: Manuel Lemos <e-mail contact>
Packages: 32 Browse all classes by Manuel Lemos Browse all classes by
Country: Portugal Portugal - PHP jobs in Portugal
Age: 44
All time rank: 1
Week rank: 3 Down1 in Portugal Portugal Equal


  Detailed description   Download .zip .tar.gz  
This package can be used to parse and filter insecure HTML tags and CSS styles.

It comes with a general purpose markup parser class that can parse any type of markup documents like HTML, XML and DTD files.

There are several other classes that can be chained together to retrieve the document token elements returned by the main markup parser class and filter the document elements in an useful way.

The markup validator filter class validates a document against a DTD, eventually removing invalid tags and attributes.

The safe HTML filter class uses several white lists to process HTML tags and data returned by the markup validator class and discards potentially harmful HTML tags and CSS that could be used to perform cross-site scripting (XSS) or cross-site request forgery (CSRF) security attacks.

The filtered HTML tokens can be reassembled to return a well-formed and secure HTML document.

The HTML links filter class can extract the links contained in an HTML document.

The DTD parser and CSS parser are utility classes used by the other classes.

  Classes of Manuel Lemos  >  Secure HTML parser and filter  >  Download .zip .tar.gz  >  Support forum Support forum (1)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Secure HTML parser and filter
Base name: secure-html-filter
Description: Parse and filter insecure HTML tags and CSS styles
Version: -
PHP version: 4
License: BSD License
All time users: 1359 users
All time rank: 2495
Week users: 5 users
Week rank: 541 Up
 
  Groups   Screenshots Screenshots   Freshmeat project   Rate classes User ratings  
  Dependencies   Trackback   Applications   Related links   Files Files  

  Groups  
Group folder image HTML HTML generation and processing View top rated classes
Group folder image Security Security protection and attack detection View top rated classes
Group folder image Parsers Programming language interpreters and format parsers View top rated classes

  Files folder image Screenshots  
Screenshot of the Web user interface to test the secure HTML filter class
File Role Description
Accessible without login Image file secure_html_filter.gif Screen Screenshot of the Web user interface to test the secure HTML filter class


  Freshmeat project  
Secure HTML parser and filter
Project record: secure-php-html-parser-and-filter
Popularity score: 63.78
Vitality score: 1.94

  User ratings  
There are not enough user ratings to display for this class.

  Packages needed by this class  
Class Dependency Why it is needed
Forms generation and validation
Conditional
Used in the secure_html_filter.php Web interface test script
Generic XML parser class
Conditional
It is neeeded to parse the xssAttacks.xml file with tested XSS attack vectors definitions
File cache class
Conditional
It is necessary to manage parsed DTD cache files

  Trackback links  
Link Description
What are the best ways to prevent XSS attacks in PHP? Now, if you really need to accept HTML formatted user input, like you need to let the user enter an HTML formatted text, you need a really powerful HTML parser that recognizes dangerous HTML or malformed tags that could be used to make JavaScript code execute when the HTML is displayed...

  Applications that use this class  
No application links were specified for this class.
Add link image If you know an application of this package, send a message to the author to add a link here.

  Related links  
Link Description
Demo Try the HTML and CSS filter here

  Files folder image Files  
File Role Description
Files folder imagedocumentation (6 files)
Files folder imagetest (1 file, 3 directories)
Accessible without login Plain text file test_safe_html_filter.php Example Example script that demonstrates how to parse and filter and HTML document file
Plain text file markup_filter_safe_html.php Class Secure HTML filter class
Plain text file css_parser.php Class CSS stylesheet parser class
Plain text file dtd_parser.php Class DTD parser class
Plain text file markup_filter_get_html_links.php Class HTML parser class to extract links from pages
Plain text file markup_filter_no_follow_html_links.php Class No follow HTML links filter class
Plain text file markup_filter_validator.php Class Filter class that validates HTML against a DTD
Plain text file markup_parser.php Class Main markup parser class
Accessible without login Plain text file secure_html_filter.php Example Script with forms to test the secure HTML filter classes
Accessible without login Plain text file test_css_parser.php Example CSS parser test script
Accessible without login Plain text file test_get_html_links.php Example Example script that demonstrates how to extract links from HTML pages
Accessible without login Plain text file test_markup_parser.php Example Example script that demonstrates how to parse any markup document into token elements
Accessible without login Plain text file test_xss_attacks.php Test Script that tests the results of the safe HTML filter class against the XSS attack vectors from ha.ckers.org

  Files  /  Files folder image documentation  
File Role Description
  Accessible without login Plain text file css_parser_class.html Doc. Documentation of the CSS parser class
  Accessible without login HTML file dtd_parser_class.html Doc. Documentation of the DTD parser class
  Accessible without login HTML file markup_filter_get_html_links_class.html Doc. Documentation of the filter get HTML links class
  Accessible without login HTML file markup_filter_safe_html_class.html Doc. Documentation of the filter HTML safe class
  Accessible without login HTML file markup_filter_validator_class.html Doc. Documentation of the filter validator class
  Accessible without login HTML file markup_parser_class.html Doc. Documentation of the main markup parser class

  Files  /  Files folder image test  
File Role Description
Files folder imageexpect (14 files)
Files folder imagegenerated (1 file)
Files folder imagesample (2 files)
  Accessible without login Plain text file test.php Test Markup parser unit test suite

  Files  /  test  /  Files folder image expect  
File Role Description
  Accessible without login Plain text file entities.txt Data Unit test expected results
  Accessible without login Plain text file entitiesinunsafeurl.txt Data Entities in unsafe URL test parsing output
  Accessible without login Plain text file quoteseparatingunsafeattribute.txt Data Quotes separating unsafe attribute test parsing output
  Accessible without login Plain text file safehtmlfilter.txt Data Test expected output
  Accessible without login Plain text file selectors.txt Data CSS selectors parsing output
  Accessible without login Plain text file simple.txt Data Unit test expected results
  Accessible without login Plain text file track_lines.txt Data Unit test expected results
  Accessible without login Plain text file unfinishedquotedtagattribute.txt Data Unit test expected results
  Accessible without login Plain text file unfinishedquotedtagattributevalue.txt Data Unit test expected results
  Accessible without login Plain text file unfinishedtag.txt Data Unit test expected results
  Accessible without login Plain text file unfinishedtagattribute.txt Data Unit test expected results
  Accessible without login Plain text file unfinishedtagattributevalue.txt Data Unit test expected results
  Accessible without login Plain text file unfinishedtagend.txt Data Unit test expected results
  Accessible without login Plain text file unicodestylevalues.txt Data Test expected output

  Files  /  test  /  Files folder image generated  
File Role Description
  Accessible without login Plain text file .cvsignore Data Dummy file to force the distribution of this directory

  Files  /  test  /  Files folder image sample  
File Role Description
  Accessible without login Plain text file simple.html Data HTML document used in the example scripts
  Accessible without login Plain text file xssAttacks.xml Data Definitions for the XSS attack vectors from ha.ckers.org

Download all files: secure-html-filter.tar.gz secure-html-filter.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.