Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43f0192

Browse files
author
Edward Z. Yang
committed
Convert to PHP 5 only codebase, adding visibility modifiers to all members and methods in the main library area (function only for test methods)
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1458 48356398-32a2-884e-a903-53898d9a118a
1 parent 85a23ba commit 43f0192

195 files changed

Lines changed: 995 additions & 1056 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

INSTALL

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ basic sanity checks to get the most out of this library.
1414
---------------------------------------------------------------------------
1515
1. Compatibility
1616

17-
HTML Purifier works in both PHP 4 and PHP 5, and is actively tested from
18-
PHP 4.3.7 and up (see tests/multitest.php for specific versions). It has
19-
no core dependencies with other libraries. PHP 4 support will be
20-
deprecated on December 31, 2007, at which time only essential security
21-
fixes will be issued for the PHP 4 version until August 8, 2008.
17+
HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.0 and
18+
up (see tests/multitest.php for the specific versions that are being
19+
actively tested). It has no core dependencies with other libraries. PHP
20+
4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0.
21+
Essential security fixes will be issued for the 2.1.x branch until
22+
August 8, 2008.
2223

2324
These optional extensions can enhance the capabilities of HTML Purifier:
2425

INSTALL.fr.utf8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ce document pour quelques choses.
1717

1818
1. Compatibilité
1919

20-
HTML Purifier fonctionne dans PHP 4 et PHP 5. PHP 4.3.2 est le dernier
20+
HTML Purifier fonctionne dans PHP 5. PHP 5.0.0 est le dernier
2121
version que je le testais. Il ne dépend de les autre librairies.
2222

2323
Les extensions optionnel est iconv (en général déjà installer) et

NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
99
. Internal change
1010
==========================
1111

12+
3.0.0, unknown release date
13+
# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained
14+
until PHP 4 is completely deprecated, but no new features will be added
15+
to it.
16+
+ Visibility declarations added
17+
1218
2.1.3, released 2007-11-05
1319
! tests/multitest.php allows you to test multiple versions by running
1420
tests/index.php through multiple interpreters using `phpv` shell

TODO

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ If no interest is expressed for a feature that may required a considerable
1111
amount of effort to implement, it may get endlessly delayed. Do not be
1212
afraid to cast your vote for the next feature to be implemented!
1313

14-
2.2 release [Error'ed]
14+
3.1 release [Error'ed]
1515
# Error logging for filtering/cleanup procedures
1616
- XSS-attempt detection
1717

18-
2.3 release [Do What I Mean, Not What I Say]
18+
3.2 release [Do What I Mean, Not What I Say]
1919
# Additional support for poorly written HTML
2020
- Microsoft Word HTML cleaning (i.e. MsoNormal, but research essential!)
2121
- Friendly strict handling of <address> (block -> <br>)
@@ -31,13 +31,13 @@ afraid to cast your vote for the next feature to be implemented!
3131
dupe detector would also need to detect the suffix as well)
3232
- Externalize inline CSS to promote clean HTML
3333

34-
2.4 release [It's All About Trust] (floating)
34+
3.3 release [It's All About Trust] (floating)
3535
# Implement untrusted, dangerous elements/attributes
3636
# Implement IDREF support (harder than it seems, since you cannot have
3737
IDREFs to non-existent IDs)
3838
# Frameset XHTML 1.0 and HTML 4.01 doctypes
3939

40-
3.0 release [Beyond HTML]
40+
4.0 release [Beyond HTML]
4141
# Legit token based CSS parsing (will require revamping almost every
4242
AttrDef class). Probably will use CSSTidy class
4343
# More control over allowed CSS properties (maybe modularize it in the
@@ -48,7 +48,7 @@ afraid to cast your vote for the next feature to be implemented!
4848
- Convert RTL/LTR override characters to <bdo> tags, or vice versa on demand.
4949
Also, enable disabling of directionality
5050

51-
4.0 release [To XML and Beyond]
51+
5.0 release [To XML and Beyond]
5252
- Extended HTML capabilities based on namespacing and tag transforms (COMPLEX)
5353
- Hooks for adding custom processors to custom namespaced tags and
5454
attributes, offer default implementation

configdoc/library/ConfigDoc.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
require_once 'ConfigDoc/XMLSerializer/Types.php';
55
require_once 'ConfigDoc/XMLSerializer/ConfigSchema.php';
66

7+
/**
8+
* Facade class for configuration documentation system
9+
*/
710
class ConfigDoc
811
{
912

10-
function generate($schema, $xsl_stylesheet_name = 'plain', $parameters = array()) {
13+
/**
14+
* Generates configuration documentation based on a HTMLPurifier_ConfigSchema
15+
* object and styleshet name
16+
* @param $schema Instance of HTMLPurifier_ConfigSchema to document
17+
* @param $xsl_stylesheet_name Name of XSL stylesheet in ../styles/ directory to use
18+
* @param $parameters Extra parameters to pass to the stylesheet
19+
* @return string HTML output
20+
*/
21+
public function generate($schema, $xsl_stylesheet_name = 'plain', $parameters = array()) {
1122
// generate types document, describing type constraints
1223
$types_serializer = new ConfigDoc_XMLSerializer_Types();
1324
$types_document = $types_serializer->serialize($schema);
@@ -29,9 +40,10 @@ function generate($schema, $xsl_stylesheet_name = 'plain', $parameters = array()
2940

3041
/**
3142
* Remove any generated files
43+
* @return boolean Success?
3244
*/
33-
function cleanup() {
34-
unlink('configdoc.xml');
45+
public function cleanup() {
46+
return unlink('configdoc.xml');
3547
}
3648

3749
}

configdoc/library/ConfigDoc/HTMLXSLTProcessor.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?php
22

33
/**
4-
* Special XSLTProcessor specifically for HTML documents. Loosely
5-
* based off of XSLTProcessor, but not really
4+
* Special XSLT processor specifically for HTML documents. Loosely
5+
* based off of XSLTProcessor, but does not inherit from that class
66
*/
77
class ConfigDoc_HTMLXSLTProcessor
88
{
99

10+
/**
11+
* Instance of XSLTProcessor
12+
*/
1013
protected $xsltProcessor;
1114

1215
public function __construct() {
@@ -16,6 +19,7 @@ public function __construct() {
1619
/**
1720
* Imports stylesheet for processor to use
1821
* @param $xsl XSLT DOM tree, or filename of the XSL transformation
22+
* @return bool Success?
1923
*/
2024
public function importStylesheet($xsl) {
2125
if (is_string($xsl)) {
@@ -27,16 +31,20 @@ public function importStylesheet($xsl) {
2731
}
2832

2933
/**
30-
* Transforms an XML file into HTML based on the stylesheet
34+
* Transforms an XML file into compatible XHTML based on the stylesheet
3135
* @param $xml XML DOM tree
36+
* @return string HTML output
37+
* @todo Rename to transformToXHTML, as transformToHTML is misleading
3238
*/
3339
public function transformToHTML($xml) {
3440
$out = $this->xsltProcessor->transformToXML($xml);
3541

3642
// fudges for HTML backwards compatibility
43+
// assumes that document is XHTML
3744
$out = str_replace('/>', ' />', $out); // <br /> not <br/>
3845
$out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns
3946
$out = str_replace(' xmlns="http://www.w3.org/1999/xhtml"', '', $out); // rm unnecessary xmlns
47+
4048
if (class_exists('Tidy')) {
4149
// cleanup output
4250
$config = array(
@@ -49,9 +57,14 @@ public function transformToHTML($xml) {
4957
$tidy->cleanRepair();
5058
$out = (string) $tidy;
5159
}
60+
5261
return $out;
5362
}
5463

64+
/**
65+
* Bulk sets parameters for the XSL stylesheet
66+
* @param array $options Associative array of options to set
67+
*/
5568
public function setParameters($options) {
5669
foreach ($options as $name => $value) {
5770
$this->xsltProcessor->setParameter('', $name, $value);

configdoc/library/ConfigDoc/XMLSerializer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@
88
class ConfigDoc_XMLSerializer
99
{
1010

11+
/**
12+
* Appends a div containing HTML into a node
13+
* @param $document Base document node belongs to
14+
* @param $node Node to append to
15+
* @param $html HTML to place inside div to append
16+
* @todo Place this directly in DOMNode, using registerNodeClass to
17+
* override.
18+
*/
1119
protected function appendHTMLDiv($document, $node, $html) {
1220
$purifier = HTMLPurifier::getInstance();
1321
$html = $purifier->purify($html);
1422
$dom_html = $document->createDocumentFragment();
1523
$dom_html->appendXML($html);
16-
1724
$dom_div = $document->createElement('div');
1825
$dom_div->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
1926
$dom_div->appendChild($dom_html);
20-
2127
$node->appendChild($dom_div);
2228
}
2329

configdoc/library/ConfigDoc/XMLSerializer/ConfigSchema.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ConfigDoc_XMLSerializer_ConfigSchema extends ConfigDoc_XMLSerializer
99
* Serializes a schema into DOM form
1010
* @todo Split into sub-serializers
1111
* @param $schema HTMLPurifier_ConfigSchema to serialize
12+
* @return DOMDocument representation of schema
1213
*/
1314
public function serialize($schema) {
1415
$dom_document = new DOMDocument('1.0', 'UTF-8');

configdoc/library/ConfigDoc/XMLSerializer/Types.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ConfigDoc_XMLSerializer_Types extends ConfigDoc_XMLSerializer
88
/**
99
* Serializes the types in a schema into DOM form
1010
* @param $schema HTMLPurifier_ConfigSchema owner of types to serialize
11+
* @return DOMDocument representing schema types
1112
*/
1213
public function serialize($schema) {
1314
$types_document = new DOMDocument('1.0', 'UTF-8');

library/HTMLPurifier.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@
8383
class HTMLPurifier
8484
{
8585

86-
var $version = '2.1.3';
86+
public $version = '2.1.3';
8787

88-
var $config;
89-
var $filters = array();
88+
public $config;
89+
public $filters = array();
9090

91-
var $strategy, $generator;
91+
protected $strategy, $generator;
9292

9393
/**
9494
* Resultant HTMLPurifier_Context of last run purification. Is an array
9595
* of contexts if the last called method was purifyArray().
9696
* @public
9797
*/
98-
var $context;
98+
public $context;
9999

100100
/**
101101
* Initializes the purifier.
@@ -105,7 +105,7 @@ class HTMLPurifier
105105
* The parameter can also be any type that
106106
* HTMLPurifier_Config::create() supports.
107107
*/
108-
function HTMLPurifier($config = null) {
108+
public function HTMLPurifier($config = null) {
109109

110110
$this->config = HTMLPurifier_Config::create($config);
111111

@@ -118,7 +118,7 @@ function HTMLPurifier($config = null) {
118118
* Adds a filter to process the output. First come first serve
119119
* @param $filter HTMLPurifier_Filter object
120120
*/
121-
function addFilter($filter) {
121+
public function addFilter($filter) {
122122
$this->filters[] = $filter;
123123
}
124124

@@ -132,7 +132,7 @@ function addFilter($filter) {
132132
* that HTMLPurifier_Config::create() supports.
133133
* @return Purified HTML
134134
*/
135-
function purify($html, $config = null) {
135+
public function purify($html, $config = null) {
136136

137137
$config = $config ? HTMLPurifier_Config::create($config) : $this->config;
138138

@@ -198,7 +198,7 @@ function purify($html, $config = null) {
198198
* See HTMLPurifier::purify() for more details.
199199
* @return Array of purified HTML
200200
*/
201-
function purifyArray($array_of_html, $config = null) {
201+
public function purifyArray($array_of_html, $config = null) {
202202
$context_array = array();
203203
foreach ($array_of_html as $key => $html) {
204204
$array_of_html[$key] = $this->purify($html, $config);
@@ -213,10 +213,10 @@ function purifyArray($array_of_html, $config = null) {
213213
* @param $prototype Optional prototype HTMLPurifier instance to
214214
* overload singleton with.
215215
*/
216-
function &getInstance($prototype = null) {
216+
public static function &getInstance($prototype = null) {
217217
static $htmlpurifier;
218218
if (!$htmlpurifier || $prototype) {
219-
if (is_a($prototype, 'HTMLPurifier')) {
219+
if ($prototype instanceof HTMLPurifier) {
220220
$htmlpurifier = $prototype;
221221
} elseif ($prototype) {
222222
$htmlpurifier = new HTMLPurifier($prototype);

0 commit comments

Comments
 (0)