Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03a6e4d
commit 88828e9
Showing
154 changed files
with
32,142 additions
and
137 deletions.
There are no files selected for viewing
22,596 changes: 22,596 additions & 0 deletions
22,596
libs/htmlpurifier-4.13.0-standalone/HTMLPurifier.standalone.php
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...lpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* Converts HTMLPurifier_ConfigSchema_Interchange to our runtime | ||
* representation used to perform checks on user configuration. | ||
*/ | ||
class HTMLPurifier_ConfigSchema_Builder_ConfigSchema | ||
{ | ||
|
||
/** | ||
* @param HTMLPurifier_ConfigSchema_Interchange $interchange | ||
* @return HTMLPurifier_ConfigSchema | ||
*/ | ||
public function build($interchange) | ||
{ | ||
$schema = new HTMLPurifier_ConfigSchema(); | ||
foreach ($interchange->directives as $d) { | ||
$schema->add( | ||
$d->id->key, | ||
$d->default, | ||
$d->type, | ||
$d->typeAllowsNull | ||
); | ||
if ($d->allowed !== null) { | ||
$schema->addAllowedValues( | ||
$d->id->key, | ||
$d->allowed | ||
); | ||
} | ||
foreach ($d->aliases as $alias) { | ||
$schema->addAlias( | ||
$alias->key, | ||
$d->id->key | ||
); | ||
} | ||
if ($d->valueAliases !== null) { | ||
$schema->addValueAliases( | ||
$d->id->key, | ||
$d->valueAliases | ||
); | ||
} | ||
} | ||
$schema->postProcess(); | ||
return $schema; | ||
} | ||
} | ||
|
||
// vim: et sw=4 sts=4 |
144 changes: 144 additions & 0 deletions
144
libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Builder/Xml.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
|
||
/** | ||
* Converts HTMLPurifier_ConfigSchema_Interchange to an XML format, | ||
* which can be further processed to generate documentation. | ||
*/ | ||
class HTMLPurifier_ConfigSchema_Builder_Xml extends XMLWriter | ||
{ | ||
|
||
/** | ||
* @type HTMLPurifier_ConfigSchema_Interchange | ||
*/ | ||
protected $interchange; | ||
|
||
/** | ||
* @type string | ||
*/ | ||
private $namespace; | ||
|
||
/** | ||
* @param string $html | ||
*/ | ||
protected function writeHTMLDiv($html) | ||
{ | ||
$this->startElement('div'); | ||
|
||
$purifier = HTMLPurifier::getInstance(); | ||
$html = $purifier->purify($html); | ||
$this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); | ||
$this->writeRaw($html); | ||
|
||
$this->endElement(); // div | ||
} | ||
|
||
/** | ||
* @param mixed $var | ||
* @return string | ||
*/ | ||
protected function export($var) | ||
{ | ||
if ($var === array()) { | ||
return 'array()'; | ||
} | ||
return var_export($var, true); | ||
} | ||
|
||
/** | ||
* @param HTMLPurifier_ConfigSchema_Interchange $interchange | ||
*/ | ||
public function build($interchange) | ||
{ | ||
// global access, only use as last resort | ||
$this->interchange = $interchange; | ||
|
||
$this->setIndent(true); | ||
$this->startDocument('1.0', 'UTF-8'); | ||
$this->startElement('configdoc'); | ||
$this->writeElement('title', $interchange->name); | ||
|
||
foreach ($interchange->directives as $directive) { | ||
$this->buildDirective($directive); | ||
} | ||
|
||
if ($this->namespace) { | ||
$this->endElement(); | ||
} // namespace | ||
|
||
$this->endElement(); // configdoc | ||
$this->flush(); | ||
} | ||
|
||
/** | ||
* @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive | ||
*/ | ||
public function buildDirective($directive) | ||
{ | ||
// Kludge, although I suppose having a notion of a "root namespace" | ||
// certainly makes things look nicer when documentation is built. | ||
// Depends on things being sorted. | ||
if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) { | ||
if ($this->namespace) { | ||
$this->endElement(); | ||
} // namespace | ||
$this->namespace = $directive->id->getRootNamespace(); | ||
$this->startElement('namespace'); | ||
$this->writeAttribute('id', $this->namespace); | ||
$this->writeElement('name', $this->namespace); | ||
} | ||
|
||
$this->startElement('directive'); | ||
$this->writeAttribute('id', $directive->id->toString()); | ||
|
||
$this->writeElement('name', $directive->id->getDirective()); | ||
|
||
$this->startElement('aliases'); | ||
foreach ($directive->aliases as $alias) { | ||
$this->writeElement('alias', $alias->toString()); | ||
} | ||
$this->endElement(); // aliases | ||
|
||
$this->startElement('constraints'); | ||
if ($directive->version) { | ||
$this->writeElement('version', $directive->version); | ||
} | ||
$this->startElement('type'); | ||
if ($directive->typeAllowsNull) { | ||
$this->writeAttribute('allow-null', 'yes'); | ||
} | ||
$this->text($directive->type); | ||
$this->endElement(); // type | ||
if ($directive->allowed) { | ||
$this->startElement('allowed'); | ||
foreach ($directive->allowed as $value => $x) { | ||
$this->writeElement('value', $value); | ||
} | ||
$this->endElement(); // allowed | ||
} | ||
$this->writeElement('default', $this->export($directive->default)); | ||
$this->writeAttribute('xml:space', 'preserve'); | ||
if ($directive->external) { | ||
$this->startElement('external'); | ||
foreach ($directive->external as $project) { | ||
$this->writeElement('project', $project); | ||
} | ||
$this->endElement(); | ||
} | ||
$this->endElement(); // constraints | ||
|
||
if ($directive->deprecatedVersion) { | ||
$this->startElement('deprecated'); | ||
$this->writeElement('version', $directive->deprecatedVersion); | ||
$this->writeElement('use', $directive->deprecatedUse->toString()); | ||
$this->endElement(); // deprecated | ||
} | ||
|
||
$this->startElement('description'); | ||
$this->writeHTMLDiv($directive->description); | ||
$this->endElement(); // description | ||
|
||
$this->endElement(); // directive | ||
} | ||
} | ||
|
||
// vim: et sw=4 sts=4 |
11 changes: 11 additions & 0 deletions
11
libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Exception.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* Exceptions related to configuration schema | ||
*/ | ||
class HTMLPurifier_ConfigSchema_Exception extends HTMLPurifier_Exception | ||
{ | ||
|
||
} | ||
|
||
// vim: et sw=4 sts=4 |
47 changes: 47 additions & 0 deletions
47
libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Interchange.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* Generic schema interchange format that can be converted to a runtime | ||
* representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members | ||
* are completely validated. | ||
*/ | ||
class HTMLPurifier_ConfigSchema_Interchange | ||
{ | ||
|
||
/** | ||
* Name of the application this schema is describing. | ||
* @type string | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* Array of Directive ID => array(directive info) | ||
* @type HTMLPurifier_ConfigSchema_Interchange_Directive[] | ||
*/ | ||
public $directives = array(); | ||
|
||
/** | ||
* Adds a directive array to $directives | ||
* @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive | ||
* @throws HTMLPurifier_ConfigSchema_Exception | ||
*/ | ||
public function addDirective($directive) | ||
{ | ||
if (isset($this->directives[$i = $directive->id->toString()])) { | ||
throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); | ||
} | ||
$this->directives[$i] = $directive; | ||
} | ||
|
||
/** | ||
* Convenience function to perform standard validation. Throws exception | ||
* on failed validation. | ||
*/ | ||
public function validate() | ||
{ | ||
$validator = new HTMLPurifier_ConfigSchema_Validator(); | ||
return $validator->validate($this); | ||
} | ||
} | ||
|
||
// vim: et sw=4 sts=4 |
89 changes: 89 additions & 0 deletions
89
...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Interchange/Directive.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
/** | ||
* Interchange component class describing configuration directives. | ||
*/ | ||
class HTMLPurifier_ConfigSchema_Interchange_Directive | ||
{ | ||
|
||
/** | ||
* ID of directive. | ||
* @type HTMLPurifier_ConfigSchema_Interchange_Id | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* Type, e.g. 'integer' or 'istring'. | ||
* @type string | ||
*/ | ||
public $type; | ||
|
||
/** | ||
* Default value, e.g. 3 or 'DefaultVal'. | ||
* @type mixed | ||
*/ | ||
public $default; | ||
|
||
/** | ||
* HTML description. | ||
* @type string | ||
*/ | ||
public $description; | ||
|
||
/** | ||
* Whether or not null is allowed as a value. | ||
* @type bool | ||
*/ | ||
public $typeAllowsNull = false; | ||
|
||
/** | ||
* Lookup table of allowed scalar values. | ||
* e.g. array('allowed' => true). | ||
* Null if all values are allowed. | ||
* @type array | ||
*/ | ||
public $allowed; | ||
|
||
/** | ||
* List of aliases for the directive. | ||
* e.g. array(new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir'))). | ||
* @type HTMLPurifier_ConfigSchema_Interchange_Id[] | ||
*/ | ||
public $aliases = array(); | ||
|
||
/** | ||
* Hash of value aliases, e.g. array('alt' => 'real'). Null if value | ||
* aliasing is disabled (necessary for non-scalar types). | ||
* @type array | ||
*/ | ||
public $valueAliases; | ||
|
||
/** | ||
* Version of HTML Purifier the directive was introduced, e.g. '1.3.1'. | ||
* Null if the directive has always existed. | ||
* @type string | ||
*/ | ||
public $version; | ||
|
||
/** | ||
* ID of directive that supercedes this old directive. | ||
* Null if not deprecated. | ||
* @type HTMLPurifier_ConfigSchema_Interchange_Id | ||
*/ | ||
public $deprecatedUse; | ||
|
||
/** | ||
* Version of HTML Purifier this directive was deprecated. Null if not | ||
* deprecated. | ||
* @type string | ||
*/ | ||
public $deprecatedVersion; | ||
|
||
/** | ||
* List of external projects this directive depends on, e.g. array('CSSTidy'). | ||
* @type array | ||
*/ | ||
public $external = array(); | ||
} | ||
|
||
// vim: et sw=4 sts=4 |
Oops, something went wrong.