mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-03-22 05:57:02 +00:00
Release 2.0.1, merged in 1181 to HEAD.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/strict@1255 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
42858ad594
commit
495164e938
2
Doxyfile
2
Doxyfile
@ -4,7 +4,7 @@
|
|||||||
# Project related configuration options
|
# Project related configuration options
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
PROJECT_NAME = HTML Purifier
|
PROJECT_NAME = HTML Purifier
|
||||||
PROJECT_NUMBER = 2.0.0
|
PROJECT_NUMBER = 2.0.1
|
||||||
OUTPUT_DIRECTORY = "C:/Documents and Settings/Edward/My Documents/My Webs/htmlpurifier/docs/doxygen"
|
OUTPUT_DIRECTORY = "C:/Documents and Settings/Edward/My Documents/My Webs/htmlpurifier/docs/doxygen"
|
||||||
CREATE_SUBDIRS = NO
|
CREATE_SUBDIRS = NO
|
||||||
OUTPUT_LANGUAGE = English
|
OUTPUT_LANGUAGE = English
|
||||||
|
53
INSTALL
53
INSTALL
@ -49,7 +49,7 @@ be standards compliant. HTML Purifier can deal with these doctypes:
|
|||||||
* XHTML 1.0 Strict
|
* XHTML 1.0 Strict
|
||||||
* HTML 4.01 Transitional
|
* HTML 4.01 Transitional
|
||||||
* HTML 4.01 Strict
|
* HTML 4.01 Strict
|
||||||
* XHTML 1.1 sans Ruby
|
* XHTML 1.1 (sans Ruby)
|
||||||
|
|
||||||
...and these character encodings:
|
...and these character encodings:
|
||||||
|
|
||||||
@ -117,8 +117,9 @@ websites):
|
|||||||
Note that HTML Purifier's support for non-Unicode encodings is crippled by the
|
Note that HTML Purifier's support for non-Unicode encodings is crippled by the
|
||||||
fact that any character not supported by that encoding will be silently
|
fact that any character not supported by that encoding will be silently
|
||||||
dropped, EVEN if it is ampersand escaped. If you want to work around
|
dropped, EVEN if it is ampersand escaped. If you want to work around
|
||||||
this, you are welcome to read docs/enduser-utf8.html for a workaround,
|
this, you are welcome to read docs/enduser-utf8.html for a fix,
|
||||||
but please be cognizant of the issues the "solution" creates.
|
but please be cognizant of the issues the "solution" creates (for this
|
||||||
|
reason, I do not include the solution in this document).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +149,9 @@ Other supported doctypes include:
|
|||||||
There are more configuration directives which can be read about
|
There are more configuration directives which can be read about
|
||||||
here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring,
|
here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring,
|
||||||
but they can help out for those of you who like to exert maximum control over
|
but they can help out for those of you who like to exert maximum control over
|
||||||
your code.
|
your code. Some of the more interesting ones are configurable at the
|
||||||
|
demo <http://htmlpurifier.org/demo.php> and are well worth looking into
|
||||||
|
for your own system.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -165,13 +168,15 @@ The interface is mind-numbingly simple:
|
|||||||
$clean_html = $purifier->purify( $dirty_html );
|
$clean_html = $purifier->purify( $dirty_html );
|
||||||
|
|
||||||
That's it! For more examples, check out docs/examples/ (they aren't very
|
That's it! For more examples, check out docs/examples/ (they aren't very
|
||||||
different though). Also, SLOW gives advice on what to do if HTML Purifier
|
different though). Also, docs/enduser-slow.html gives advice on what to
|
||||||
is slowing down your application.
|
do if HTML Purifier is slowing down your application.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
6. Quick install
|
6. Quick install
|
||||||
|
|
||||||
|
First, make sure library/HTMLPurifier/DefinitionCache/Serializer is
|
||||||
|
writable by the webserver (see Section 7: Caching below for details).
|
||||||
If your website is in UTF-8 and XHTML Transitional, use this code:
|
If your website is in UTF-8 and XHTML Transitional, use this code:
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@ -198,6 +203,36 @@ If your website is in a different encoding or doctype, use this code:
|
|||||||
|
|
||||||
7. Caching
|
7. Caching
|
||||||
|
|
||||||
HTML Purifier generates some cache files to speed up its execution. For
|
HTML Purifier generates some cache files (generally one or two) to speed up
|
||||||
maximum performance, make sure that library/HTMLPurifier/DefinitionCache/Serializer
|
its execution. For maximum performance, make sure that
|
||||||
is writeable by the webserver.
|
library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver.
|
||||||
|
|
||||||
|
If you are in the library/ folder of HTML Purifier, you can set the
|
||||||
|
appropriate permissions using:
|
||||||
|
|
||||||
|
chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer
|
||||||
|
|
||||||
|
If the above command doesn't work, you may need to assign write permissions
|
||||||
|
to all. This may be necessary if your webserver runs as nobody, but is
|
||||||
|
not recommended since it means any other user can write files in the
|
||||||
|
directory. Use:
|
||||||
|
|
||||||
|
chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer
|
||||||
|
|
||||||
|
You can also chmod files via your FTP client; this option
|
||||||
|
is usually accessible by right clicking the corresponding directory and
|
||||||
|
then selecting "chmod" or "file permissions".
|
||||||
|
|
||||||
|
Starting with 2.0.1, HTML Purifier will generate friendly error messages
|
||||||
|
that will tell you exactly what you have to chmod the directory to, if in doubt,
|
||||||
|
follow its advice.
|
||||||
|
|
||||||
|
If you are unable or unwilling to give write permissions to the cache
|
||||||
|
directory, you can either disable the cache (and suffer a performance
|
||||||
|
hit):
|
||||||
|
|
||||||
|
$config->set('Core', 'DefinitionCache', null);
|
||||||
|
|
||||||
|
Or move the cache directory somewhere else (no trailing slash):
|
||||||
|
|
||||||
|
$config->set('Cache', 'SerializerPath', '/home/user/absolute/path');
|
||||||
|
44
NEWS
44
NEWS
@ -9,6 +9,50 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
. Internal change
|
. Internal change
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
2.0.1, released 2007-06-27
|
||||||
|
! Tag auto-closing now based on a ChildDef heuristic rather than a
|
||||||
|
manually set auto_close array; some behavior may change
|
||||||
|
! Experimental AutoFormat functionality added: auto-paragraph and
|
||||||
|
linkify your HTML input by setting %AutoFormat.AutoParagraph and
|
||||||
|
%AutoFormat.Linkify to true
|
||||||
|
! Newlines normalized internally, and then converted back to the
|
||||||
|
value of PHP_EOL. If this is not desired, set your newline format
|
||||||
|
using %Output.Newline.
|
||||||
|
! Beta error collection, messages are implemented for the most generic
|
||||||
|
cases involving Lexing or Strategies
|
||||||
|
- Clean up special case code for <script> tags
|
||||||
|
- Reorder includes for DefinitionCache decorators, fixes a possible
|
||||||
|
missing class error
|
||||||
|
- Fixed bug where manually modified definitions were not saved via cache
|
||||||
|
(mostly harmless, except for the fact that it would be a little slower)
|
||||||
|
- Configuration objects with different serials do not clobber each
|
||||||
|
others when revision numbers are unequal
|
||||||
|
- Improve Serializer DefinitionCache directory permissions checks
|
||||||
|
- DefinitionCache no longer throws errors when it encounters old
|
||||||
|
serial files that do not conform to the current style
|
||||||
|
- Stray xmlns attributes removed from configuration documentation
|
||||||
|
- configForm.php smoketest no longer has XSS vulnerability due to
|
||||||
|
unescaped print_r output
|
||||||
|
- Printer adheres to configuration's directives on output format
|
||||||
|
- Fix improperly named form field in ConfigForm printer
|
||||||
|
. Rewire some test-cases to swallow errors rather than expect them
|
||||||
|
. HTMLDefinition printer updated with some of the new attributes
|
||||||
|
. DefinitionCache keys reordered to reflect precedence: version number,
|
||||||
|
hash, then revision number
|
||||||
|
. %Core.DefinitionCache renamed to %Cache.DefinitionImpl
|
||||||
|
. Interlinking in configuration documentation added using
|
||||||
|
Injector_PurifierLinkify
|
||||||
|
. Directives now keep track of aliases to themselves
|
||||||
|
. Error collector now requires a severity to be passed, use PHP's internal
|
||||||
|
error constants for this
|
||||||
|
. HTMLPurifier_Config::getAllowedDirectivesForForm implemented, allows
|
||||||
|
much easier selective embedding of configuration values
|
||||||
|
. Doctype objects now accept public and system DTD identifiers
|
||||||
|
. %HTML.Doctype is now constrained by specific values, to specify a custom
|
||||||
|
doctype use new %HTML.CustomDoctype
|
||||||
|
. ConfigForm truncates long directives to keep the form small, and does
|
||||||
|
not re-output namespaces
|
||||||
|
|
||||||
2.0.0, released 2007-06-20
|
2.0.0, released 2007-06-20
|
||||||
# Completely refactored HTMLModuleManager, decentralizing safety
|
# Completely refactored HTMLModuleManager, decentralizing safety
|
||||||
information
|
information
|
||||||
|
38
TODO
38
TODO
@ -7,31 +7,17 @@ TODO List
|
|||||||
==========================
|
==========================
|
||||||
|
|
||||||
2.1 release [Refactor, refactor!]
|
2.1 release [Refactor, refactor!]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# URI validation routines tighter (see docs/dev-code-quality.html) (COMPLEX)
|
# URI validation routines tighter (see docs/dev-code-quality.html) (COMPLEX)
|
||||||
# Advanced URI filtering schemes (see docs/proposal-new-directives.txt)
|
# Advanced URI filtering schemes (see docs/proposal-new-directives.txt)
|
||||||
|
# Ruby support
|
||||||
- Configuration profiles: predefined directives set with one func call
|
- Configuration profiles: predefined directives set with one func call
|
||||||
- Implement IDREF support (harder than it seems, since you cannot have
|
- Implement IDREF support (harder than it seems, since you cannot have
|
||||||
IDREFs to non-existent IDs)
|
IDREFs to non-existent IDs)
|
||||||
- Allow non-ASCII characters in font names
|
- Allow non-ASCII characters in font names
|
||||||
- Genericize special cases in RemoveForeignElements
|
|
||||||
|
|
||||||
2.2 release [Error'ed]
|
2.2 release [Error'ed]
|
||||||
# Error logging for filtering/cleanup procedures
|
# Error logging for filtering/cleanup procedures
|
||||||
- Requires I18N facilities to be created first (COMPLEX)
|
|
||||||
- XSS-attempt detection
|
- XSS-attempt detection
|
||||||
- More fine-grained control over escaping behavior
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2.3 release [Do What I Mean, Not What I Say]
|
2.3 release [Do What I Mean, Not What I Say]
|
||||||
# Additional support for poorly written HTML
|
# Additional support for poorly written HTML
|
||||||
@ -56,14 +42,9 @@ TODO List
|
|||||||
AttrDef class)
|
AttrDef class)
|
||||||
# More control over allowed CSS properties (maybe modularize it in the
|
# More control over allowed CSS properties (maybe modularize it in the
|
||||||
same fashion!)
|
same fashion!)
|
||||||
# Formatters for plaintext (COMPLEX)
|
# Formatters for plaintext
|
||||||
- Auto-paragraphing (be sure to leverage fact that we know when things
|
|
||||||
shouldn't be paragraphed, such as lists and tables).
|
|
||||||
- Linkify URLs
|
|
||||||
- Smileys
|
- Smileys
|
||||||
- Linkification for HTML Purifier docs: notably configuration and classes
|
- Standardize token armor for all areas of processing
|
||||||
- Allow tags to be "armored", an internal flag that protects them
|
|
||||||
from validation and passes them out unharmed
|
|
||||||
- Fixes for Firefox's inability to handle COL alignment props (Bug 915)
|
- Fixes for Firefox's inability to handle COL alignment props (Bug 915)
|
||||||
- Automatically add non-breaking spaces to empty table cells when
|
- Automatically add non-breaking spaces to empty table cells when
|
||||||
empty-cells:show is applied to have compatibility with Internet Explorer
|
empty-cells:show is applied to have compatibility with Internet Explorer
|
||||||
@ -75,12 +56,13 @@ TODO List
|
|||||||
- Hooks for adding custom processors to custom namespaced tags and
|
- Hooks for adding custom processors to custom namespaced tags and
|
||||||
attributes, offer default implementation
|
attributes, offer default implementation
|
||||||
- Lots of documentation and samples
|
- Lots of documentation and samples
|
||||||
- XHTML 1.1 support
|
|
||||||
|
|
||||||
Ongoing
|
Ongoing
|
||||||
- Lots of profiling, make it faster!
|
- Lots of profiling, make it faster!
|
||||||
- Plugins for major CMSes (COMPLEX)
|
- Plugins for major CMSes (COMPLEX)
|
||||||
- WordPress (mostly written, needs beta-testing)
|
- WordPress (mostly written, needs beta-testing)
|
||||||
|
- phpBB
|
||||||
|
- Phorum
|
||||||
- eFiction
|
- eFiction
|
||||||
- more! (look for ones that use WYSIWYGs)
|
- more! (look for ones that use WYSIWYGs)
|
||||||
- Complete basic smoketests
|
- Complete basic smoketests
|
||||||
@ -89,7 +71,8 @@ Unknown release (on a scratch-an-itch basis)
|
|||||||
? Semi-lossy dumb alternate character encoding transfor
|
? Semi-lossy dumb alternate character encoding transfor
|
||||||
? Have 'lang' attribute be checked against official lists, achieved by
|
? Have 'lang' attribute be checked against official lists, achieved by
|
||||||
encoding all characters that have string entity equivalents
|
encoding all characters that have string entity equivalents
|
||||||
- Explain how to use HTML Purifier in non-PHP languages
|
- Explain how to use HTML Purifier in non-PHP languages / create
|
||||||
|
a simple command line stub
|
||||||
- Abstract ChildDef_BlockQuote to work with all elements that only
|
- Abstract ChildDef_BlockQuote to work with all elements that only
|
||||||
allow blocks in them, required or optional
|
allow blocks in them, required or optional
|
||||||
- Reorganize Unit Tests
|
- Reorganize Unit Tests
|
||||||
@ -97,10 +80,11 @@ Unknown release (on a scratch-an-itch basis)
|
|||||||
- Reorganize configuration directives (Create more namespaces! Get messy!)
|
- Reorganize configuration directives (Create more namespaces! Get messy!)
|
||||||
|
|
||||||
Requested
|
Requested
|
||||||
? Native content compression, whitespace stripping (don't rely on Tidy, make
|
|
||||||
sure we don't remove from <pre> or related tags)
|
|
||||||
|
|
||||||
Wontfix
|
Wontfix
|
||||||
- Non-lossy smart alternate character encoding transformations (unless
|
- Non-lossy smart alternate character encoding transformations (unless
|
||||||
patch provided)
|
patch provided)
|
||||||
- Pretty-printing HTML, users can use Tidy on the output on entire page
|
- Pretty-printing HTML, users can use Tidy on the output on entire page
|
||||||
|
- Native content compression, whitespace stripping (don't rely on Tidy, make
|
||||||
|
sure we don't remove from <pre> or related tags): use gzip if this is
|
||||||
|
really important
|
||||||
|
19
WHATSNEW
19
WHATSNEW
@ -1,7 +1,12 @@
|
|||||||
HTML Purifier 2.0 is the culmination of two major architectural changes.
|
The 2.0.1 release introduces a number of stability and usability fixes,
|
||||||
The first is Tidy, which enables HTML Purifier to both natively support
|
as well as a number of (disabled by default) experimental features. The
|
||||||
deprecated elements and also convert them to standards-compliant
|
security-minded should note that a reflected XSS vulnerability was patched
|
||||||
alternatives. The second is the Advanced API, which enables users to
|
in smoketests/configForm.php; if you cannot upgrade immediately, please
|
||||||
create new elements and attributes with ease. Keeping in line with a
|
delete that file (if that directory is not publically accessible, there
|
||||||
commitment to high quality, there are also five esoteric bug-fixes and a
|
is no security risk). The maintenance changes include more helpful file
|
||||||
plethora of subtle improvements that enhance the library.
|
permissions errors, internal newline normalization, reordered includes
|
||||||
|
to prevent a missing class definition in some setups, and better cache
|
||||||
|
revision and id handling. The two experimental features are auto-formatting
|
||||||
|
(auto-paragraphing and linkification) and error collection, these can
|
||||||
|
be enabled with %AutoFormat.AutoParagraph, %AutoFormat.Linkify and
|
||||||
|
%Core.CollectErrors respectively.
|
||||||
|
BIN
art/100cases.png
Normal file
BIN
art/100cases.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
@ -165,4 +165,4 @@ echo '<div>Random input was: ' .
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -15,5 +15,3 @@ $context = new HTMLPurifier_Context();
|
|||||||
for ($i = 0; $i < 10; $i++) {
|
for ($i = 0; $i < 10; $i++) {
|
||||||
$tokens = $lexer->tokenizeHTML($input, $config, $context);
|
$tokens = $lexer->tokenizeHTML($input, $config, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -22,6 +22,10 @@ error_reporting(E_ALL); // probably not possible to use E_STRICT
|
|||||||
require_once '../library/HTMLPurifier.auto.php';
|
require_once '../library/HTMLPurifier.auto.php';
|
||||||
require_once 'library/ConfigDoc.auto.php';
|
require_once 'library/ConfigDoc.auto.php';
|
||||||
|
|
||||||
|
$purifier = HTMLPurifier::getInstance(array(
|
||||||
|
'AutoFormat.PurifierLinkify' => true
|
||||||
|
));
|
||||||
|
|
||||||
$schema = HTMLPurifier_ConfigSchema::instance();
|
$schema = HTMLPurifier_ConfigSchema::instance();
|
||||||
$style = 'plain'; // use $_GET in the future
|
$style = 'plain'; // use $_GET in the future
|
||||||
$configdoc = new ConfigDoc();
|
$configdoc = new ConfigDoc();
|
||||||
@ -37,4 +41,3 @@ if (php_sapi_name() != 'cli') {
|
|||||||
echo 'Files generated successfully.';
|
echo 'Files generated successfully.';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -7,4 +7,3 @@
|
|||||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
||||||
require_once 'ConfigDoc.php';
|
require_once 'ConfigDoc.php';
|
||||||
|
|
||||||
?>
|
|
@ -36,4 +36,3 @@ class ConfigDoc
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -36,6 +36,7 @@ class ConfigDoc_HTMLXSLTProcessor
|
|||||||
// fudges for HTML backwards compatibility
|
// fudges for HTML backwards compatibility
|
||||||
$out = str_replace('/>', ' />', $out); // <br /> not <br/>
|
$out = str_replace('/>', ' />', $out); // <br /> not <br/>
|
||||||
$out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns
|
$out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns
|
||||||
|
$out = str_replace(' xmlns="http://www.w3.org/1999/xhtml"', '', $out); // rm unnecessary xmlns
|
||||||
if (class_exists('Tidy')) {
|
if (class_exists('Tidy')) {
|
||||||
// cleanup output
|
// cleanup output
|
||||||
$config = array(
|
$config = array(
|
||||||
@ -59,4 +60,3 @@ class ConfigDoc_HTMLXSLTProcessor
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -23,4 +23,3 @@ class ConfigDoc_XMLSerializer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -50,6 +50,12 @@ class ConfigDoc_XMLSerializer_ConfigSchema extends ConfigDoc_XMLSerializer
|
|||||||
$dom_document->createElement('name', $name)
|
$dom_document->createElement('name', $name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$dom_aliases = $dom_document->createElement('aliases');
|
||||||
|
$dom_directive->appendChild($dom_aliases);
|
||||||
|
foreach ($info->directiveAliases as $alias) {
|
||||||
|
$dom_aliases->appendChild($dom_document->createElement('alias', $alias));
|
||||||
|
}
|
||||||
|
|
||||||
$dom_constraints = $dom_document->createElement('constraints');
|
$dom_constraints = $dom_document->createElement('constraints');
|
||||||
$dom_directive->appendChild($dom_constraints);
|
$dom_directive->appendChild($dom_constraints);
|
||||||
|
|
||||||
@ -115,4 +121,3 @@ class ConfigDoc_XMLSerializer_ConfigSchema extends ConfigDoc_XMLSerializer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -24,4 +24,3 @@ class ConfigDoc_XMLSerializer_Types extends ConfigDoc_XMLSerializer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -72,8 +72,16 @@
|
|||||||
<xsl:apply-templates />
|
<xsl:apply-templates />
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
<xsl:template match="directive/name">
|
<xsl:template match="directive/name">
|
||||||
|
<xsl:apply-templates select="../aliases/alias" mode="anchor" />
|
||||||
<h3 id="{../@id}"><xsl:value-of select="../@id" /></h3>
|
<h3 id="{../@id}"><xsl:value-of select="../@id" /></h3>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
<xsl:template match="alias" mode="anchor">
|
||||||
|
<a id="{.}"></a>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<!-- Do not pass through -->
|
||||||
|
<xsl:template match="alias"></xsl:template>
|
||||||
|
|
||||||
<xsl:template match="directive/constraints">
|
<xsl:template match="directive/constraints">
|
||||||
<table class="constraints">
|
<table class="constraints">
|
||||||
<xsl:apply-templates />
|
<xsl:apply-templates />
|
||||||
@ -89,8 +97,20 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</xsl:if>
|
</xsl:if>
|
||||||
|
<xsl:if test="../aliases/alias">
|
||||||
|
<xsl:apply-templates select="../aliases" mode="constraints" />
|
||||||
|
</xsl:if>
|
||||||
</table>
|
</table>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
<xsl:template match="directive/aliases" mode="constraints">
|
||||||
|
<th>Aliases:</th>
|
||||||
|
<td>
|
||||||
|
<xsl:for-each select="alias">
|
||||||
|
<xsl:if test="position()>1">, </xsl:if>
|
||||||
|
<xsl:value-of select="." />
|
||||||
|
</xsl:for-each>
|
||||||
|
</td>
|
||||||
|
</xsl:template>
|
||||||
<xsl:template match="directive//description">
|
<xsl:template match="directive//description">
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<xsl:copy-of select="div/node()" />
|
<xsl:copy-of select="div/node()" />
|
||||||
@ -128,4 +148,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
</xsl:stylesheet>
|
</xsl:stylesheet>
|
||||||
|
@ -210,4 +210,4 @@ the usual things required are:</p>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -79,4 +79,4 @@ help you find the correct functionality more quickly. Here they are:</p>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -30,4 +30,4 @@ that itch, put it here!</p>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -299,4 +299,4 @@ Mozilla on inside and needs -moz-outline, no IE support.</td></tr>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -17,11 +17,6 @@
|
|||||||
<div id="index">Return to the <a href="index.html">index</a>.</div>
|
<div id="index">Return to the <a href="index.html">index</a>.</div>
|
||||||
<div id="home"><a href="http://htmlpurifier.org/">HTML Purifier</a> End-User Documentation</div>
|
<div id="home"><a href="http://htmlpurifier.org/">HTML Purifier</a> End-User Documentation</div>
|
||||||
|
|
||||||
<div id="applicability">
|
|
||||||
This document covers currently unreleased functionality and
|
|
||||||
only applies to recent SVN checkouts.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You may have heard of the <a href="dev-advanced-api.html">Advanced API</a>.
|
You may have heard of the <a href="dev-advanced-api.html">Advanced API</a>.
|
||||||
If you're interested in reading dry prose and boring functional
|
If you're interested in reading dry prose and boring functional
|
||||||
@ -788,4 +783,4 @@ $form->excludes = array('form' => true);</strong></pre>
|
|||||||
|
|
||||||
<div id="version">$Id: enduser-tidy.html 1158 2007-06-18 19:26:29Z Edward $</div>
|
<div id="version">$Id: enduser-tidy.html 1158 2007-06-18 19:26:29Z Edward $</div>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -144,4 +144,4 @@ anchors is beyond me.</p>
|
|||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -114,4 +114,4 @@ if you decide to do that! Especially if you port HTML Purifier to C++.
|
|||||||
<tt>;-)</tt></p>
|
<tt>;-)</tt></p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -16,11 +16,6 @@
|
|||||||
<div id="index">Return to the <a href="index.html">index</a>.</div>
|
<div id="index">Return to the <a href="index.html">index</a>.</div>
|
||||||
<div id="home"><a href="http://htmlpurifier.org/">HTML Purifier</a> End-User Documentation</div>
|
<div id="home"><a href="http://htmlpurifier.org/">HTML Purifier</a> End-User Documentation</div>
|
||||||
|
|
||||||
<div id="applicability">
|
|
||||||
This document covers currently unreleased functionality and
|
|
||||||
only applies to recent SVN checkouts.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>You've probably heard of HTML Tidy, Dave Raggett's little piece
|
<p>You've probably heard of HTML Tidy, Dave Raggett's little piece
|
||||||
of software that cleans up poorly written HTML. Let me say it straight
|
of software that cleans up poorly written HTML. Let me say it straight
|
||||||
out:</p>
|
out:</p>
|
||||||
@ -232,4 +227,4 @@ effectively in the background.</p>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -1043,4 +1043,4 @@ a more in-depth look into character sets and encodings.</p>
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -149,4 +149,4 @@ like that, for that matter), send it over and it might get included
|
|||||||
with the core!</p>
|
with the core!</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -20,4 +20,3 @@ $pure_html = $purifier->purify($html);
|
|||||||
|
|
||||||
echo '<pre>' . htmlspecialchars($pure_html) . '</pre>';
|
echo '<pre>' . htmlspecialchars($pure_html) . '</pre>';
|
||||||
|
|
||||||
?>
|
|
@ -162,4 +162,4 @@ the code. They may be upgraded to HTML files or stay as TXT scratchpads.</p>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -42,4 +42,4 @@ the development of this library in these forum threads:</p>
|
|||||||
|
|
||||||
<div id="version">$Id$</div>
|
<div id="version">$Id$</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -21,4 +21,4 @@ HTML Purifier context.
|
|||||||
<xmp>, monospace, replace with pre
|
<xmp>, monospace, replace with pre
|
||||||
|
|
||||||
These should be put into their own Tidy module, not loaded by default(?). These
|
These should be put into their own Tidy module, not loaded by default(?). These
|
||||||
all qualify as "lenient" transforms.
|
all qualify as "lenient" transforms.
|
||||||
|
@ -7,4 +7,3 @@
|
|||||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
||||||
require_once 'HTMLPurifier.php';
|
require_once 'HTMLPurifier.php';
|
||||||
|
|
||||||
?>
|
|
@ -18,4 +18,3 @@ function HTMLPurifier($html, $config = null) {
|
|||||||
return $purifier->purify($html, $config);
|
return $purifier->purify($html, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
HTML Purifier 2.0.0 - Standards Compliant HTML Filtering
|
HTML Purifier 2.0.1 - Standards Compliant HTML Filtering
|
||||||
Copyright (C) 2006 Edward Z. Yang
|
Copyright (C) 2006 Edward Z. Yang
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
@ -51,16 +51,9 @@ require_once 'HTMLPurifier/Generator.php';
|
|||||||
require_once 'HTMLPurifier/Strategy/Core.php';
|
require_once 'HTMLPurifier/Strategy/Core.php';
|
||||||
require_once 'HTMLPurifier/Encoder.php';
|
require_once 'HTMLPurifier/Encoder.php';
|
||||||
|
|
||||||
|
require_once 'HTMLPurifier/ErrorCollector.php';
|
||||||
require_once 'HTMLPurifier/LanguageFactory.php';
|
require_once 'HTMLPurifier/LanguageFactory.php';
|
||||||
|
|
||||||
HTMLPurifier_ConfigSchema::define(
|
|
||||||
'Core', 'Language', 'en', 'string', '
|
|
||||||
ISO 639 language code for localizable things in HTML Purifier to use,
|
|
||||||
which is mainly error reporting. There is currently only an English (en)
|
|
||||||
translation, so this directive is currently useless.
|
|
||||||
This directive has been available since 2.0.0.
|
|
||||||
');
|
|
||||||
|
|
||||||
HTMLPurifier_ConfigSchema::define(
|
HTMLPurifier_ConfigSchema::define(
|
||||||
'Core', 'CollectErrors', false, 'bool', '
|
'Core', 'CollectErrors', false, 'bool', '
|
||||||
Whether or not to collect errors found while filtering the document. This
|
Whether or not to collect errors found while filtering the document. This
|
||||||
@ -81,7 +74,7 @@ This directive has been available since 2.0.0.
|
|||||||
class HTMLPurifier
|
class HTMLPurifier
|
||||||
{
|
{
|
||||||
|
|
||||||
var $version = '2.0.0';
|
var $version = '2.0.1';
|
||||||
|
|
||||||
var $config;
|
var $config;
|
||||||
var $filters;
|
var $filters;
|
||||||
@ -139,15 +132,19 @@ class HTMLPurifier
|
|||||||
|
|
||||||
$context = new HTMLPurifier_Context();
|
$context = new HTMLPurifier_Context();
|
||||||
|
|
||||||
|
// our friendly neighborhood generator, all primed with configuration too!
|
||||||
|
$this->generator->generateFromTokens(array(), $config, $context);
|
||||||
|
$context->register('Generator', $this->generator);
|
||||||
|
|
||||||
// set up global context variables
|
// set up global context variables
|
||||||
if ($config->get('Core', 'CollectErrors')) {
|
if ($config->get('Core', 'CollectErrors')) {
|
||||||
// may get moved out if other facilities use it
|
// may get moved out if other facilities use it
|
||||||
$language_factory = HTMLPurifier_LanguageFactory::instance();
|
$language_factory = HTMLPurifier_LanguageFactory::instance();
|
||||||
$language = $language_factory->create($config->get('Core', 'Language'));
|
$language = $language_factory->create($config, $context);
|
||||||
$context->register('Locale', $language);
|
$context->register('Locale', $language);
|
||||||
|
|
||||||
$error_collector = new HTMLPurifier_ErrorCollector();
|
$error_collector = new HTMLPurifier_ErrorCollector($context);
|
||||||
$context->register('ErrorCollector', $language);
|
$context->register('ErrorCollector', $error_collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
|
$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
|
||||||
@ -216,4 +213,3 @@ class HTMLPurifier
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -127,4 +127,3 @@ class HTMLPurifier_AttrCollections
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -84,4 +84,3 @@ class HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -66,4 +66,3 @@ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -84,4 +84,3 @@ class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -127,4 +127,3 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -42,4 +42,3 @@ class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -98,4 +98,3 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -35,4 +35,3 @@ class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -148,4 +148,3 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -59,4 +59,3 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -53,4 +53,3 @@ class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -77,4 +77,3 @@ class HTMLPurifier_AttrDef_CSS_ListStyle extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -55,4 +55,3 @@ class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -58,4 +58,3 @@ class HTMLPurifier_AttrDef_CSS_Number extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -40,4 +40,3 @@ class HTMLPurifier_AttrDef_CSS_Percentage extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -34,4 +34,3 @@ class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -55,4 +55,3 @@ class HTMLPurifier_AttrDef_CSS_URI extends HTMLPurifier_AttrDef_URI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -63,4 +63,3 @@ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -27,4 +27,3 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -32,4 +32,3 @@ class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -31,4 +31,3 @@ class HTMLPurifier_AttrDef_HTML_FrameTarget extends HTMLPurifier_AttrDef_Enum
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -118,4 +118,3 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -41,4 +41,3 @@ class HTMLPurifier_AttrDef_HTML_Length extends HTMLPurifier_AttrDef_HTML_Pixels
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -70,4 +70,3 @@ class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -41,4 +41,3 @@ class HTMLPurifier_AttrDef_HTML_MultiLength extends HTMLPurifier_AttrDef_HTML_Le
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -48,4 +48,3 @@ class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -34,4 +34,3 @@ class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -72,4 +72,3 @@ class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -72,4 +72,3 @@ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -14,4 +14,3 @@ class HTMLPurifier_AttrDef_Text extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -302,4 +302,4 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -14,4 +14,3 @@ class HTMLPurifier_AttrDef_URI_Email extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -20,4 +20,3 @@ class HTMLPurifier_AttrDef_URI_Email_SimpleCheck extends HTMLPurifier_AttrDef_UR
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -51,4 +51,3 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -39,4 +39,3 @@ class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -98,4 +98,3 @@ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -55,4 +55,3 @@ class HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -28,4 +28,3 @@ class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -23,4 +23,3 @@ extends HTMLPurifier_AttrTransform {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -36,4 +36,3 @@ extends HTMLPurifier_AttrTransform {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -17,4 +17,3 @@ class HTMLPurifier_AttrTransform_Border extends HTMLPurifier_AttrTransform {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -57,4 +57,3 @@ class HTMLPurifier_AttrTransform_EnumToCSS extends HTMLPurifier_AttrTransform {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -51,4 +51,3 @@ class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -44,4 +44,3 @@ extends HTMLPurifier_AttrTransform {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -27,4 +27,3 @@ class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -26,4 +26,3 @@ class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -18,4 +18,3 @@ class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -79,4 +79,4 @@ class HTMLPurifier_AttrTypes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,32 +1,53 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the attributes of a token. Doesn't manage required attributes
|
||||||
|
* very well. The only reason we factored this out was because RemoveForeignElements
|
||||||
|
* also needed it besides ValidateAttributes.
|
||||||
|
*/
|
||||||
class HTMLPurifier_AttrValidator
|
class HTMLPurifier_AttrValidator
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
function validateToken($token, &$config, &$context) {
|
* Validates the attributes of a token, returning a modified token
|
||||||
|
* that has valid tokens
|
||||||
|
* @param $token Reference to token to validate. We require a reference
|
||||||
|
* because the operation this class performs on the token are
|
||||||
|
* not atomic, so the context CurrentToken to be updated
|
||||||
|
* throughout
|
||||||
|
* @param $config Instance of HTMLPurifier_Config
|
||||||
|
* @param $context Instance of HTMLPurifier_Context
|
||||||
|
*/
|
||||||
|
function validateToken(&$token, &$config, &$context) {
|
||||||
|
|
||||||
$definition = $config->getHTMLDefinition();
|
$definition = $config->getHTMLDefinition();
|
||||||
|
$e =& $context->get('ErrorCollector', true);
|
||||||
|
|
||||||
|
// initialize CurrentToken if necessary
|
||||||
|
$current_token =& $context->get('CurrentToken', true);
|
||||||
|
if (!$current_token) $context->register('CurrentToken', $token);
|
||||||
|
|
||||||
|
if ($token->type !== 'start' && $token->type !== 'empty') return $token;
|
||||||
|
|
||||||
// create alias to global definition array, see also $defs
|
// create alias to global definition array, see also $defs
|
||||||
// DEFINITION CALL
|
// DEFINITION CALL
|
||||||
$d_defs = $definition->info_global_attr;
|
$d_defs = $definition->info_global_attr;
|
||||||
|
|
||||||
// copy out attributes for easy manipulation
|
// reference attributes for easy manipulation
|
||||||
$attr = $token->attr;
|
$attr =& $token->attr;
|
||||||
|
|
||||||
// do global transformations (pre)
|
// do global transformations (pre)
|
||||||
// nothing currently utilizes this
|
// nothing currently utilizes this
|
||||||
foreach ($definition->info_attr_transform_pre as $transform) {
|
foreach ($definition->info_attr_transform_pre as $transform) {
|
||||||
$attr = $transform->transform($attr, $config, $context);
|
$attr = $transform->transform($o = $attr, $config, $context);
|
||||||
|
if ($e && ($attr != $o)) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do local transformations only applicable to this element (pre)
|
// do local transformations only applicable to this element (pre)
|
||||||
// ex. <p align="right"> to <p style="text-align:right;">
|
// ex. <p align="right"> to <p style="text-align:right;">
|
||||||
foreach ($definition->info[$token->name]->attr_transform_pre
|
foreach ($definition->info[$token->name]->attr_transform_pre as $transform) {
|
||||||
as $transform
|
$attr = $transform->transform($o = $attr, $config, $context);
|
||||||
) {
|
if ($e && ($attr != $o)) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr);
|
||||||
$attr = $transform->transform($attr, $config, $context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create alias to this element's attribute definition array, see
|
// create alias to this element's attribute definition array, see
|
||||||
@ -34,6 +55,9 @@ class HTMLPurifier_AttrValidator
|
|||||||
// DEFINITION CALL
|
// DEFINITION CALL
|
||||||
$defs = $definition->info[$token->name]->attr;
|
$defs = $definition->info[$token->name]->attr;
|
||||||
|
|
||||||
|
$attr_key = false;
|
||||||
|
$context->register('CurrentAttr', $attr_key);
|
||||||
|
|
||||||
// iterate through all the attribute keypairs
|
// iterate through all the attribute keypairs
|
||||||
// Watch out for name collisions: $key has previously been used
|
// Watch out for name collisions: $key has previously been used
|
||||||
foreach ($attr as $attr_key => $value) {
|
foreach ($attr as $attr_key => $value) {
|
||||||
@ -67,9 +91,17 @@ class HTMLPurifier_AttrValidator
|
|||||||
|
|
||||||
// put the results into effect
|
// put the results into effect
|
||||||
if ($result === false || $result === null) {
|
if ($result === false || $result === null) {
|
||||||
|
// this is a generic error message that should replaced
|
||||||
|
// with more specific ones when possible
|
||||||
|
if ($e) $e->send(E_ERROR, 'AttrValidator: Attribute removed');
|
||||||
|
|
||||||
// remove the attribute
|
// remove the attribute
|
||||||
unset($attr[$attr_key]);
|
unset($attr[$attr_key]);
|
||||||
} elseif (is_string($result)) {
|
} elseif (is_string($result)) {
|
||||||
|
// generally, if a substitution is happening, there
|
||||||
|
// was some sort of implicit correction going on. We'll
|
||||||
|
// delegate it to the attribute classes to say exactly what.
|
||||||
|
|
||||||
// simple substitution
|
// simple substitution
|
||||||
$attr[$attr_key] = $result;
|
$attr[$attr_key] = $result;
|
||||||
}
|
}
|
||||||
@ -81,25 +113,27 @@ class HTMLPurifier_AttrValidator
|
|||||||
// others would prepend themselves).
|
// others would prepend themselves).
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$context->destroy('CurrentAttr');
|
||||||
|
|
||||||
// post transforms
|
// post transforms
|
||||||
|
|
||||||
// ex. <x lang="fr"> to <x lang="fr" xml:lang="fr">
|
// global (error reporting untested)
|
||||||
foreach ($definition->info_attr_transform_post as $transform) {
|
foreach ($definition->info_attr_transform_post as $transform) {
|
||||||
$attr = $transform->transform($attr, $config, $context);
|
$attr = $transform->transform($o = $attr, $config, $context);
|
||||||
|
if ($e && ($attr != $o)) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ex. <bdo> to <bdo dir="ltr">
|
// local (error reporting untested)
|
||||||
foreach ($definition->info[$token->name]->attr_transform_post as $transform) {
|
foreach ($definition->info[$token->name]->attr_transform_post as $transform) {
|
||||||
$attr = $transform->transform($attr, $config, $context);
|
$attr = $transform->transform($o = $attr, $config, $context);
|
||||||
|
if ($e && ($attr != $o)) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit changes
|
// destroy CurrentToken if we made it ourselves
|
||||||
$token->attr = $attr;
|
if (!$current_token) $context->destroy('CurrentToken');
|
||||||
return $token;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -226,4 +226,3 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -36,6 +36,11 @@ class HTMLPurifier_ChildDef
|
|||||||
*/
|
*/
|
||||||
var $allow_empty;
|
var $allow_empty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup array of all elements that this definition could possibly allow
|
||||||
|
*/
|
||||||
|
var $elements = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates nodes according to definition and returns modification.
|
* Validates nodes according to definition and returns modification.
|
||||||
*
|
*
|
||||||
@ -52,4 +57,4 @@ class HTMLPurifier_ChildDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -35,6 +35,7 @@ class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef
|
|||||||
function HTMLPurifier_ChildDef_Chameleon($inline, $block) {
|
function HTMLPurifier_ChildDef_Chameleon($inline, $block) {
|
||||||
$this->inline = new HTMLPurifier_ChildDef_Optional($inline);
|
$this->inline = new HTMLPurifier_ChildDef_Optional($inline);
|
||||||
$this->block = new HTMLPurifier_ChildDef_Optional($block);
|
$this->block = new HTMLPurifier_ChildDef_Optional($block);
|
||||||
|
$this->elements = $this->block->elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateChildren($tokens_of_children, $config, &$context) {
|
function validateChildren($tokens_of_children, $config, &$context) {
|
||||||
@ -48,4 +49,3 @@ class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -44,6 +44,12 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
|
|||||||
// COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M
|
// COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M
|
||||||
// DOING! Seriously: if there's problems, please report them.
|
// DOING! Seriously: if there's problems, please report them.
|
||||||
|
|
||||||
|
// collect all elements into the $elements array
|
||||||
|
preg_match_all("/$el/", $reg, $matches);
|
||||||
|
foreach ($matches[0] as $match) {
|
||||||
|
$this->elements[$match] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// setup all elements as parentheticals with leading commas
|
// setup all elements as parentheticals with leading commas
|
||||||
$reg = preg_replace("/$el/", '(,\\0)', $reg);
|
$reg = preg_replace("/$el/", '(,\\0)', $reg);
|
||||||
|
|
||||||
@ -85,4 +91,3 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -19,4 +19,3 @@ class HTMLPurifier_ChildDef_Empty extends HTMLPurifier_ChildDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -20,4 +20,3 @@ class HTMLPurifier_ChildDef_Optional extends HTMLPurifier_ChildDef_Required
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -25,7 +25,7 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
|
|||||||
$elements = array_flip($elements);
|
$elements = array_flip($elements);
|
||||||
foreach ($elements as $i => $x) {
|
foreach ($elements as $i => $x) {
|
||||||
$elements[$i] = true;
|
$elements[$i] = true;
|
||||||
if (empty($i)) unset($elements[$i]);
|
if (empty($i)) unset($elements[$i]); // remove blank
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->elements = $elements;
|
$this->elements = $elements;
|
||||||
@ -109,4 +109,3 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -73,4 +73,3 @@ extends HTMLPurifier_ChildDef_Required
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -9,6 +9,8 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef
|
|||||||
{
|
{
|
||||||
var $allow_empty = false;
|
var $allow_empty = false;
|
||||||
var $type = 'table';
|
var $type = 'table';
|
||||||
|
var $elements = array('tr' => true, 'tbody' => true, 'thead' => true,
|
||||||
|
'tfoot' => true, 'caption' => true, 'colgroup' => true, 'col' => true);
|
||||||
function HTMLPurifier_ChildDef_Table() {}
|
function HTMLPurifier_ChildDef_Table() {}
|
||||||
function validateChildren($tokens_of_children, $config, &$context) {
|
function validateChildren($tokens_of_children, $config, &$context) {
|
||||||
if (empty($tokens_of_children)) return false;
|
if (empty($tokens_of_children)) return false;
|
||||||
@ -139,4 +141,3 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -41,7 +41,7 @@ class HTMLPurifier_Config
|
|||||||
/**
|
/**
|
||||||
* HTML Purifier's version
|
* HTML Purifier's version
|
||||||
*/
|
*/
|
||||||
var $version = '2.0.0';
|
var $version = '2.0.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Two-level associative array of configuration directives
|
* Two-level associative array of configuration directives
|
||||||
@ -152,11 +152,15 @@ class HTMLPurifier_Config
|
|||||||
/**
|
/**
|
||||||
* Returns a md5 signature of a segment of the configuration object
|
* Returns a md5 signature of a segment of the configuration object
|
||||||
* that uniquely identifies that particular configuration
|
* that uniquely identifies that particular configuration
|
||||||
|
* @note Revision is handled specially and is removed from the batch
|
||||||
|
* before processing!
|
||||||
* @param $namespace Namespace to get serial for
|
* @param $namespace Namespace to get serial for
|
||||||
*/
|
*/
|
||||||
function getBatchSerial($namespace) {
|
function getBatchSerial($namespace) {
|
||||||
if (empty($this->serials[$namespace])) {
|
if (empty($this->serials[$namespace])) {
|
||||||
$this->serials[$namespace] = md5(serialize($this->getBatch($namespace)));
|
$batch = $this->getBatch($namespace);
|
||||||
|
unset($batch['DefinitionRev']);
|
||||||
|
$this->serials[$namespace] = md5(serialize($batch));
|
||||||
}
|
}
|
||||||
return $this->serials[$namespace];
|
return $this->serials[$namespace];
|
||||||
}
|
}
|
||||||
@ -243,14 +247,16 @@ class HTMLPurifier_Config
|
|||||||
* called before it's been setup, otherwise won't work.
|
* called before it's been setup, otherwise won't work.
|
||||||
*/
|
*/
|
||||||
function &getHTMLDefinition($raw = false) {
|
function &getHTMLDefinition($raw = false) {
|
||||||
return $this->getDefinition('HTML', $raw);
|
$def =& $this->getDefinition('HTML', $raw);
|
||||||
|
return $def; // prevent PHP 4.4.0 from complaining
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves reference to the CSS definition
|
* Retrieves reference to the CSS definition
|
||||||
*/
|
*/
|
||||||
function &getCSSDefinition($raw = false) {
|
function &getCSSDefinition($raw = false) {
|
||||||
return $this->getDefinition('CSS', $raw);
|
$def =& $this->getDefinition('CSS', $raw);
|
||||||
|
return $def;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,6 +273,7 @@ class HTMLPurifier_Config
|
|||||||
if (!empty($this->definitions[$type])) {
|
if (!empty($this->definitions[$type])) {
|
||||||
if (!$this->definitions[$type]->setup) {
|
if (!$this->definitions[$type]->setup) {
|
||||||
$this->definitions[$type]->setup($this);
|
$this->definitions[$type]->setup($this);
|
||||||
|
$cache->set($this->definitions[$type], $this);
|
||||||
}
|
}
|
||||||
return $this->definitions[$type];
|
return $this->definitions[$type];
|
||||||
}
|
}
|
||||||
@ -298,7 +305,7 @@ class HTMLPurifier_Config
|
|||||||
if (is_null($this->get($type, 'DefinitionID'))) {
|
if (is_null($this->get($type, 'DefinitionID'))) {
|
||||||
// fatally error out if definition ID not set
|
// fatally error out if definition ID not set
|
||||||
trigger_error("Cannot retrieve raw version without specifying %$type.DefinitionID", E_USER_ERROR);
|
trigger_error("Cannot retrieve raw version without specifying %$type.DefinitionID", E_USER_ERROR);
|
||||||
$false = false;
|
$false = new HTMLPurifier_Error();
|
||||||
return $false;
|
return $false;
|
||||||
}
|
}
|
||||||
return $this->definitions[$type];
|
return $this->definitions[$type];
|
||||||
@ -333,25 +340,78 @@ class HTMLPurifier_Config
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of array(namespace, directive) for all directives
|
||||||
|
* that are allowed in a web-form context as per an allowed
|
||||||
|
* namespaces/directives list.
|
||||||
|
* @param $allowed List of allowed namespaces/directives
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
static function getAllowedDirectivesForForm($allowed) {
|
||||||
|
$schema = HTMLPurifier_ConfigSchema::instance();
|
||||||
|
if ($allowed !== true) {
|
||||||
|
if (is_string($allowed)) $allowed = array($allowed);
|
||||||
|
$allowed_ns = array();
|
||||||
|
$allowed_directives = array();
|
||||||
|
$blacklisted_directives = array();
|
||||||
|
foreach ($allowed as $ns_or_directive) {
|
||||||
|
if (strpos($ns_or_directive, '.') !== false) {
|
||||||
|
// directive
|
||||||
|
if ($ns_or_directive[0] == '-') {
|
||||||
|
$blacklisted_directives[substr($ns_or_directive, 1)] = true;
|
||||||
|
} else {
|
||||||
|
$allowed_directives[$ns_or_directive] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// namespace
|
||||||
|
$allowed_ns[$ns_or_directive] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ret = array();
|
||||||
|
foreach ($schema->info as $ns => $keypairs) {
|
||||||
|
foreach ($keypairs as $directive => $def) {
|
||||||
|
if ($allowed !== true) {
|
||||||
|
if (isset($blacklisted_directives["$ns.$directive"])) continue;
|
||||||
|
if (!isset($allowed_directives["$ns.$directive"]) && !isset($allowed_ns[$ns])) continue;
|
||||||
|
}
|
||||||
|
if ($def->class == 'alias') continue;
|
||||||
|
if ($directive == 'DefinitionID' || $directive == 'DefinitionRev') continue;
|
||||||
|
$ret[] = array($ns, $directive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads configuration values from $_GET/$_POST that were posted
|
* Loads configuration values from $_GET/$_POST that were posted
|
||||||
* via ConfigForm
|
* via ConfigForm
|
||||||
* @param $array $_GET or $_POST array to import
|
* @param $array $_GET or $_POST array to import
|
||||||
* @param $index Index/name that the config variables are in
|
* @param $index Index/name that the config variables are in
|
||||||
|
* @param $allowed List of allowed namespaces/directives
|
||||||
* @param $mq_fix Boolean whether or not to enable magic quotes fix
|
* @param $mq_fix Boolean whether or not to enable magic quotes fix
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function loadArrayFromForm($array, $index, $mq_fix = true) {
|
static function loadArrayFromForm($array, $index, $allowed = true, $mq_fix = true) {
|
||||||
$array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
|
$array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
|
||||||
$mq = get_magic_quotes_gpc() && $mq_fix;
|
$mq = get_magic_quotes_gpc() && $mq_fix;
|
||||||
foreach ($array as $key => $value) {
|
|
||||||
if (!strncmp($key, 'Null_', 5) && !empty($value)) {
|
$allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed);
|
||||||
unset($array[substr($key, 5)]);
|
$ret = array();
|
||||||
unset($array[$key]);
|
foreach ($allowed as $key) {
|
||||||
|
list($ns, $directive) = $key;
|
||||||
|
$skey = "$ns.$directive";
|
||||||
|
if (!empty($array["Null_$skey"])) {
|
||||||
|
$ret[$ns][$directive] = null;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if ($mq) $array[$key] = stripslashes($value);
|
if (!isset($array[$skey])) continue;
|
||||||
|
$value = $mq ? stripslashes($array[$skey]) : $array[$skey];
|
||||||
|
$ret[$ns][$directive] = $value;
|
||||||
}
|
}
|
||||||
return @HTMLPurifier_Config::create($array);
|
|
||||||
|
$config = HTMLPurifier_Config::create($ret);
|
||||||
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -392,4 +452,4 @@ class HTMLPurifier_Config
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -7,4 +7,3 @@ class HTMLPurifier_ConfigDef {
|
|||||||
var $class = false;
|
var $class = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -61,6 +61,12 @@ class HTMLPurifier_ConfigDef_Directive extends HTMLPurifier_ConfigDef
|
|||||||
*/
|
*/
|
||||||
var $aliases = array();
|
var $aliases = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advisory list of directive aliases, i.e. other directives that
|
||||||
|
* redirect here
|
||||||
|
*/
|
||||||
|
var $directiveAliases = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a description to the array
|
* Adds a description to the array
|
||||||
*/
|
*/
|
||||||
@ -71,4 +77,3 @@ class HTMLPurifier_ConfigDef_Directive extends HTMLPurifier_ConfigDef
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -24,4 +24,3 @@ class HTMLPurifier_ConfigDef_DirectiveAlias extends HTMLPurifier_ConfigDef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -20,4 +20,3 @@ class HTMLPurifier_ConfigDef_Namespace extends HTMLPurifier_ConfigDef {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -67,6 +67,8 @@ class HTMLPurifier_ConfigSchema {
|
|||||||
$this->defineNamespace('URI', 'Features regarding Uniform Resource Identifiers.');
|
$this->defineNamespace('URI', 'Features regarding Uniform Resource Identifiers.');
|
||||||
$this->defineNamespace('HTML', 'Configuration regarding allowed HTML.');
|
$this->defineNamespace('HTML', 'Configuration regarding allowed HTML.');
|
||||||
$this->defineNamespace('CSS', 'Configuration regarding allowed CSS.');
|
$this->defineNamespace('CSS', 'Configuration regarding allowed CSS.');
|
||||||
|
$this->defineNamespace('AutoFormat', 'Configuration for activating auto-formatting functionality (also known as <code>Injector</code>s)');
|
||||||
|
$this->defineNamespace('AutoFormatParam', 'Configuration for customizing auto-formatting functionality');
|
||||||
$this->defineNamespace('Output', 'Configuration relating to the generation of (X)HTML.');
|
$this->defineNamespace('Output', 'Configuration relating to the generation of (X)HTML.');
|
||||||
$this->defineNamespace('Cache', 'Configuration for DefinitionCache and related subclasses.');
|
$this->defineNamespace('Cache', 'Configuration for DefinitionCache and related subclasses.');
|
||||||
$this->defineNamespace('Test', 'Developer testing configuration for our unit tests.');
|
$this->defineNamespace('Test', 'Developer testing configuration for our unit tests.');
|
||||||
@ -293,6 +295,7 @@ class HTMLPurifier_ConfigSchema {
|
|||||||
$def->info[$namespace][$name] =
|
$def->info[$namespace][$name] =
|
||||||
new HTMLPurifier_ConfigDef_DirectiveAlias(
|
new HTMLPurifier_ConfigDef_DirectiveAlias(
|
||||||
$new_namespace, $new_name);
|
$new_namespace, $new_name);
|
||||||
|
$def->info[$new_namespace][$new_name]->directiveAliases[] = "$namespace.$name";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -401,4 +404,4 @@ class HTMLPurifier_ConfigSchema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -147,4 +147,3 @@ class HTMLPurifier_ContentSets
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Registry object that contains information about the current context.
|
* Registry object that contains information about the current context.
|
||||||
|
* @warning Is a bit buggy when variables are set to null: it thinks
|
||||||
|
* they don't exist! So use false instead, please.
|
||||||
*/
|
*/
|
||||||
class HTMLPurifier_Context
|
class HTMLPurifier_Context
|
||||||
{
|
{
|
||||||
@ -19,7 +21,7 @@ class HTMLPurifier_Context
|
|||||||
*/
|
*/
|
||||||
function register($name, &$ref) {
|
function register($name, &$ref) {
|
||||||
if (isset($this->_storage[$name])) {
|
if (isset($this->_storage[$name])) {
|
||||||
trigger_error('Name collision, cannot re-register',
|
trigger_error("Name $name produces collision, cannot re-register",
|
||||||
E_USER_ERROR);
|
E_USER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -29,11 +31,14 @@ class HTMLPurifier_Context
|
|||||||
/**
|
/**
|
||||||
* Retrieves a variable reference from the context.
|
* Retrieves a variable reference from the context.
|
||||||
* @param $name String name
|
* @param $name String name
|
||||||
|
* @param $ignore_error Boolean whether or not to ignore error
|
||||||
*/
|
*/
|
||||||
function &get($name) {
|
function &get($name, $ignore_error = false) {
|
||||||
if (!isset($this->_storage[$name])) {
|
if (!isset($this->_storage[$name])) {
|
||||||
trigger_error('Attempted to retrieve non-existent variable',
|
if (!$ignore_error) {
|
||||||
E_USER_ERROR);
|
trigger_error("Attempted to retrieve non-existent variable $name",
|
||||||
|
E_USER_ERROR);
|
||||||
|
}
|
||||||
$var = null; // so we can return by reference
|
$var = null; // so we can return by reference
|
||||||
return $var;
|
return $var;
|
||||||
}
|
}
|
||||||
@ -46,7 +51,7 @@ class HTMLPurifier_Context
|
|||||||
*/
|
*/
|
||||||
function destroy($name) {
|
function destroy($name) {
|
||||||
if (!isset($this->_storage[$name])) {
|
if (!isset($this->_storage[$name])) {
|
||||||
trigger_error('Attempted to destroy non-existent variable',
|
trigger_error("Attempted to destroy non-existent variable $name",
|
||||||
E_USER_ERROR);
|
E_USER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,4 +78,3 @@ class HTMLPurifier_Context
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user