Skip to content
Permalink
Browse files
sanitize input
  • Loading branch information
Mariotti94 committed Oct 14, 2021
1 parent 03a6e4d commit 88828e99e5176c3a425419104ff4c2effe3da3fa
Showing with 32,142 additions and 137 deletions.
  1. +22,596 −0 libs/htmlpurifier-4.13.0-standalone/HTMLPurifier.standalone.php
  2. +48 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php
  3. +144 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Builder/Xml.php
  4. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Exception.php
  5. +47 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Interchange.php
  6. +89 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Interchange/Directive.php
  7. +58 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Interchange/Id.php
  8. +226 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/InterchangeBuilder.php
  9. +248 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/Validator.php
  10. +130 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/ValidatorAtom.php
  11. +1 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema.ser
  12. +8 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt
  13. +12 −0 ...rifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt
  14. +9 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt
  15. +9 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt
  16. +19 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt
  17. +11 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt
  18. +9 −0 ...rifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt
  19. +8 −0 ...ier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt
  20. +10 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt
  21. +16 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt
  22. +8 −0 ...lpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt
  23. +10 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt
  24. +5 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt
  25. +9 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt
  26. +12 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt
  27. +14 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt
  28. +31 −0 ...rifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt
  29. +12 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt
  30. +11 −0 ...ifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt
  31. +12 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt
  32. +12 −0 ...13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt
  33. +12 −0 ...fier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt
  34. +14 −0 ....13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt
  35. +11 −0 ...lone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt
  36. +15 −0 ...13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt
  37. +46 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt
  38. +11 −0 ...tandalone/standalone/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt
  39. +11 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt
  40. +8 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt
  41. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt
  42. +12 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt
  43. +18 −0 ...lpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt
  44. +11 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt
  45. +13 −0 ...urifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt
  46. +16 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt
  47. +10 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt
  48. +9 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt
  49. +14 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt
  50. +13 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt
  51. +16 −0 ...ier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt
  52. +18 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt
  53. +16 −0 ...r-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt
  54. +16 −0 ...er-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt
  55. +12 −0 ...urifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt
  56. +12 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt
  57. +160 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt
  58. +14 −0 ...-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt
  59. +17 −0 ...0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt
  60. +14 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt
  61. +9 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt
  62. +15 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt
  63. +12 −0 ...fier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt
  64. +7 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt
  65. +13 −0 ...r-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt
  66. +19 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt
  67. +10 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.Language.txt
  68. +36 −0 ...rifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt
  69. +34 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt
  70. +16 −0 ...rifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt
  71. +11 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt
  72. +12 −0 ...lpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt
  73. +11 −0 ...13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt
  74. +12 −0 ...ifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt
  75. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt
  76. +14 −0 ...3.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt
  77. +29 −0 ...4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt
  78. +16 −0 ...3.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt
  79. +74 −0 ...ifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt
  80. +16 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt
  81. +25 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt
  82. +19 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt
  83. +10 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt
  84. +15 −0 ...fier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt
  85. +23 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt
  86. +20 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt
  87. +11 −0 ...urifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt
  88. +18 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt
  89. +23 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt
  90. +9 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt
  91. +33 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt
  92. +16 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt
  93. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt
  94. +11 −0 ...ifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt
  95. +21 −0 ...rifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt
  96. +20 −0 ...purifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt
  97. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt
  98. +14 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt
  99. +7 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt
  100. +12 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt
  101. +12 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt
  102. +13 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt
  103. +13 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt
  104. +13 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt
  105. +10 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt
  106. +9 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt
  107. +8 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt
  108. +10 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt
  109. +9 −0 ...lpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt
  110. +8 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt
  111. +24 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt
  112. +8 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt
  113. +9 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt
  114. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt
  115. +10 −0 ...er-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt
  116. +15 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt
  117. +11 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt
  118. +13 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt
  119. +14 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt
  120. +25 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt
  121. +7 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt
  122. +18 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt
  123. +17 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.Base.txt
  124. +15 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt
  125. +11 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt
  126. +11 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt
  127. +14 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt
  128. +11 −0 ...tmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt
  129. +13 −0 ...er-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt
  130. +15 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt
  131. +19 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.Host.txt
  132. +9 −0 .../htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt
  133. +13 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt
  134. +83 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt
  135. +17 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt
  136. +30 −0 ...htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt
  137. +9 −0 ...fier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt
  138. +22 −0 ...mlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt
  139. +3 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/ConfigSchema/schema/info.ini
  140. BIN ...TMLPurifier/DefinitionCache/Serializer/HTML/4.13.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser
  141. +1 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/EntityLookup/entities.ser
  142. +341 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Filter/ExtractStyleBlocks.php
  143. +65 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Filter/YouTube.php
  144. +55 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Language/messages/en.php
  145. +4,788 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Lexer/PH5P.php
  146. +218 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Printer.php
  147. +44 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Printer/CSSDefinition.php
  148. +10 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Printer/ConfigForm.css
  149. +5 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Printer/ConfigForm.js
  150. +451 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Printer/ConfigForm.php
  151. +324 −0 libs/htmlpurifier-4.13.0-standalone/standalone/HTMLPurifier/Printer/HTMLDefinition.php
  152. +1 −0 src/assembler.php
  153. +139 −137 src/elements.php
  154. +17 −0 src/functions.php

Large diffs are not rendered by default.

@@ -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
@@ -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
@@ -0,0 +1,11 @@
<?php

/**
* Exceptions related to configuration schema
*/
class HTMLPurifier_ConfigSchema_Exception extends HTMLPurifier_Exception
{

}

// vim: et sw=4 sts=4
@@ -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
@@ -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

0 comments on commit 88828e9

Please sign in to comment.