Login   Register  
PHP Classes
elePHPant
Icontem

File: documentation/css_parser_class.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Manuel Lemos  >  Secure HTML parser and filter  >  documentation/css_parser_class.html  >  Download  
File: documentation/css_parser_class.html
Role: Documentation
Content type: text/plain
Description: Documentation of the CSS parser class
Class: Secure HTML parser and filter
Parse and filter insecure HTML tags and CSS styles
Author: By
Last change: Fixed the role.
Date: 3 years ago
Size: 11,336 bytes
 

Contents

Class file image Download
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Class: CSS parser</title>
</head>
<body>
<center><h1>Class: CSS parser</h1></center>
<hr />
<ul>
<p><b>Version:</b> <tt>@(#) $Id: css_parser.php,v 1.20 2010/05/08 01:39:08 mlemos Exp $</tt></p>
<h2><a name="table_of_contents">Contents</a></h2>
<ul>
<li><a href="#2.1.1">Summary</a></li>
<ul>
<li><a href="#3.2.0">Name</a></li>
<li><a href="#3.2.0.0">Author</a></li>
<li><a href="#3.2.0.1">Copyright</a></li>
<li><a href="#3.2.0.2">Version</a></li>
<li><a href="#3.2.0.3">Purpose</a></li>
<li><a href="#3.2.0.4">Usage</a></li>
</ul>
<li><a href="#4.1.1">Variables</a></li>
<ul>
<li><a href="#5.2.8">error</a></li>
<li><a href="#5.2.9">error_position</a></li>
<li><a href="#5.2.10">ignore_syntax_errors</a></li>
<li><a href="#5.2.11">warnings</a></li>
<li><a href="#5.2.12">store_positions</a></li>
<li><a href="#5.2.13">track_lines</a></li>
<li><a href="#5.2.14">allow_internet_explorer_hacks</a></li>
</ul>
<li><a href="#6.1.1">Functions</a></li>
<ul>
<li><a href="#7.2.6">GetPositionLine</a></li>
<li><a href="#9.2.7">ParseStyleProperties</a></li>
<li><a href="#11.2.8">ParseStylesheet</a></li>
<li><a href="#13.2.9">RewriteStyleProperties</a></li>
<li><a href="#15.2.10">RewriteStyle</a></li>
</ul>
</ul>
<p><a href="#table_of_contents">Top of the table of contents</a></p>
</ul>
<hr />
<ul>
<h2><li><a name="2.1.1">Summary</a></li></h2>
<ul>
<h3><a name="3.2.0">Name</a></h3>
<p>CSS parser</p>
<h3><a name="3.2.0.0">Author</a></h3>
<p>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</p>
<h3><a name="3.2.0.1">Copyright</a></h3>
<p>Copyright &copy; (C) Manuel Lemos 2009</p>
<h3><a name="3.2.0.2">Version</a></h3>
<p>@(#) $Id: css_parser.php,v 1.20 2010/05/08 01:39:08 mlemos Exp $</p>
<h3><a name="3.2.0.3">Purpose</a></h3>
<p>.</p>
<h3><a name="3.2.0.4">Usage</a></h3>
<p>.</p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="variables"></a><a name="4.1.1">Variables</a></li></h2>
<ul>
<li><tt><a href="#variable_error">error</a></tt></li><br />
<li><tt><a href="#variable_error_position">error_position</a></tt></li><br />
<li><tt><a href="#variable_ignore_syntax_errors">ignore_syntax_errors</a></tt></li><br />
<li><tt><a href="#variable_warnings">warnings</a></tt></li><br />
<li><tt><a href="#variable_store_positions">store_positions</a></tt></li><br />
<li><tt><a href="#variable_track_lines">track_lines</a></tt></li><br />
<li><tt><a href="#variable_allow_internet_explorer_hacks">allow_internet_explorer_hacks</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="variable_error"></a><li><a name="5.2.8">error</a></li></h3>
<h3>Type</h3>
<p><tt><i>string</i></tt></p>
<h3>Default value</h3>
<p><tt>''</tt></p>
<h3>Purpose</h3>
<p>Store the message that is returned when an error occurs.</p>
<h3>Usage</h3>
<p>Check this variable to understand what happened when a call to any of the class functions has failed.</p>
<p> This class uses cumulative error handling. This means that if one class functions that may fail is called and this variable was already set to an error message due to a failure in a previous call to the same or other function, the function will also fail and does not do anything.</p>
<p> This allows programs using this class to safely call several functions that may fail and only check the failure condition after the last function call.</p>
<p> Just set this variable to an empty string to clear the error condition.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_error_position"></a><li><a name="5.2.9">error_position</a></li></h3>
<h3>Type</h3>
<p><tt><i>int</i></tt></p>
<h3>Default value</h3>
<p><tt>-1</tt></p>
<h3>Purpose</h3>
<p>Point to the position of the markup data or file that refers to the last error that occurred.</p>
<h3>Usage</h3>
<p>Check this variable to determine the relevant position of the document when a parsing error occurs.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_ignore_syntax_errors"></a><li><a name="5.2.10">ignore_syntax_errors</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>Specify whether the class should ignore syntax errors in malformed documents.</p>
<h3>Usage</h3>
<p>Set this variable to 0 if it is necessary to verify whether markup data may be corrupted due to to eventual bugs in the program that generated the document.</p>
<p> Currently the class only ignores some types of syntax errors. Other syntax errors may still cause the <tt><a href="#function_Parse">Parse</a></tt> to fail.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_warnings"></a><li><a name="5.2.11">warnings</a></li></h3>
<h3>Type</h3>
<p><tt><i>array</i></tt></p>
<h3>Default value</h3>
<p><tt>array()</tt></p>
<h3>Purpose</h3>
<p>Return a list of positions of the original document that contain syntax errors.</p>
<h3>Usage</h3>
<p>Check this variable to retrieve eventual document syntax errors that were ignored when the <tt><a href="#variable_ignore_syntax_errors">ignore_syntax_errors</a></tt> is set to 1.</p>
<p> The indexes of this array are the positions of the errors. The array values are the corresponding syntax error messages.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_store_positions"></a><li><a name="5.2.12">store_positions</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>.</p>
<h3>Usage</h3>
<p>.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_track_lines"></a><li><a name="5.2.13">track_lines</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>0</tt></p>
<h3>Purpose</h3>
<p>.</p>
<h3>Usage</h3>
<p>.</p>
<p><a href="#variables">Variables</a></p>
<h3><a name="variable_allow_internet_explorer_hacks"></a><li><a name="5.2.14">allow_internet_explorer_hacks</a></li></h3>
<h3>Type</h3>
<p><tt><i>bool</i></tt></p>
<h3>Default value</h3>
<p><tt>1</tt></p>
<h3>Purpose</h3>
<p>.</p>
<h3>Usage</h3>
<p>.</p>
<p><a href="#variables">Variables</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>
<hr />
<ul>
<h2><li><a name="functions"></a><a name="6.1.1">Functions</a></li></h2>
<ul>
<li><tt><a href="#function_GetPositionLine">GetPositionLine</a></tt></li><br />
<li><tt><a href="#function_ParseStyleProperties">ParseStyleProperties</a></tt></li><br />
<li><tt><a href="#function_ParseStylesheet">ParseStylesheet</a></tt></li><br />
<li><tt><a href="#function_RewriteStyleProperties">RewriteStyleProperties</a></tt></li><br />
<li><tt><a href="#function_RewriteStyle">RewriteStyle</a></tt></li><br />
<p><a href="#table_of_contents">Table of contents</a></p>
<h3><a name="function_GetPositionLine"></a><li><a name="7.2.6">GetPositionLine</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> GetPositionLine(</tt><ul>
<tt><i>int</i> </tt><tt><a href="#argument_GetPositionLine_position">position</a></tt><tt>,</tt><br />
<tt>(output) <i>int &amp;</i> </tt><tt><a href="#argument_GetPositionLine_line">line</a></tt><tt>,</tt><br />
<tt>(output) <i>int &amp;</i> </tt><tt><a href="#argument_GetPositionLine_column">column</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>.</p>
<h3>Usage</h3>
<p>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_GetPositionLine_position">position</a></b></tt> - .</p>
<p><tt><b><a name="argument_GetPositionLine_line">line</a></b></tt> - .</p>
<p><tt><b><a name="argument_GetPositionLine_column">column</a></b></tt> - .</p>
</ul>
<h3>Return value</h3>
<p>.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_ParseStyleProperties"></a><li><a name="9.2.7">ParseStyleProperties</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> ParseStyleProperties(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_ParseStyleProperties_value">value</a></tt><tt>,</tt><br />
<tt>(output) <i>array</i> </tt><tt><a href="#argument_ParseStyleProperties_properties">properties</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Parse and extract style properties eventually from style definition sections in HTML pages.</p>
<h3>Usage</h3>
<p>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_ParseStyleProperties_value">value</a></b></tt> - String with the style properties to parse.</p>
<p><tt><b><a name="argument_ParseStyleProperties_properties">properties</a></b></tt> - .</p>
</ul>
<h3>Return value</h3>
<p>.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_ParseStylesheet"></a><li><a name="11.2.8">ParseStylesheet</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> ParseStylesheet(</tt><ul>
<tt><i>string</i> </tt><tt><a href="#argument_ParseStylesheet_stylesheet">stylesheet</a></tt><tt>,</tt><br />
<tt>(output) <i>array</i> </tt><tt><a href="#argument_ParseStylesheet_properties">properties</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>Parse and extract stylesheets eventually from stylesheet files or sections in HTML pages.</p>
<h3>Usage</h3>
<p>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_ParseStylesheet_stylesheet">stylesheet</a></b></tt> - String with the stylesheet to parse.</p>
<p><tt><b><a name="argument_ParseStylesheet_properties">properties</a></b></tt> - .</p>
</ul>
<h3>Return value</h3>
<p>.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_RewriteStyleProperties"></a><li><a name="13.2.9">RewriteStyleProperties</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> RewriteStyleProperties(</tt><ul>
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_RewriteStyleProperties_properties">properties</a></tt><tt>,</tt><br />
<tt>(output) <i>string &amp;</i> </tt><tt><a href="#argument_RewriteStyleProperties_rewrite">rewrite</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>.</p>
<h3>Usage</h3>
<p>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_RewriteStyleProperties_properties">properties</a></b></tt> - .</p>
<p><tt><b><a name="argument_RewriteStyleProperties_rewrite">rewrite</a></b></tt> - .</p>
</ul>
<h3>Return value</h3>
<p>.</p>
<p><a href="#functions">Functions</a></p>
<h3><a name="function_RewriteStyle"></a><li><a name="15.2.10">RewriteStyle</a></li></h3>
<h3>Synopsis</h3>
<p><tt><i>bool</i> RewriteStyle(</tt><ul>
<tt>(input and output) <i>array</i> </tt><tt><a href="#argument_RewriteStyle_style">style</a></tt><tt>,</tt><br />
<tt>(output) <i>string &amp;</i> </tt><tt><a href="#argument_RewriteStyle_rewrite">rewrite</a></tt></ul>
<tt>)</tt></p>
<h3>Purpose</h3>
<p>.</p>
<h3>Usage</h3>
<p>.</p>
<h3>Arguments</h3>
<ul>
<p><tt><b><a name="argument_RewriteStyle_style">style</a></b></tt> - .</p>
<p><tt><b><a name="argument_RewriteStyle_rewrite">rewrite</a></b></tt> - .</p>
</ul>
<h3>Return value</h3>
<p>.</p>
<p><a href="#functions">Functions</a></p>
<p><a href="#table_of_contents">Table of contents</a></p>
</ul>
</ul>

<hr />
<address>Manuel Lemos (<a href="mailto:mlemos-at-acm.org">mlemos-at-acm.org</a>)</address>
</body>
</html>