collection = new TemplateCheckList; $this->collection->append('DisallowAttributeSets'); $this->collection->append('DisallowCopy'); $this->collection->append('DisallowDisableOutputEscaping'); $this->collection->append('DisallowDynamicAttributeNames'); $this->collection->append('DisallowDynamicElementNames'); $this->collection->append('DisallowObjectParamsWithGeneratedName'); $this->collection->append('DisallowPHPTags'); $this->collection->append('DisallowUnsafeCopyOf'); $this->collection->append('DisallowUnsafeDynamicCSS'); $this->collection->append('DisallowUnsafeDynamicJS'); $this->collection->append('DisallowUnsafeDynamicURL'); $this->collection->append(new DisallowElementNS('http://icl.com/saxon', 'output')); $this->collection->append(new DisallowXPathFunction('document')); $this->collection->append(new RestrictFlashScriptAccess('sameDomain', true)); // Check for unsupported XSL last to allow for the more specialized checks to be run first $this->collection->append('DisallowUnsupportedXSL'); } /** * Check a given tag's templates for disallowed content * * @param Tag $tag Tag whose templates will be checked * @return void */ public function checkTag(Tag $tag) { if (isset($tag->template) && !($tag->template instanceof UnsafeTemplate)) { $template = (string) $tag->template; $this->checkTemplate($template, $tag); } } /** * Check a given template for disallowed content * * @param string $template Template * @param Tag $tag Tag this template belongs to * @return void */ public function checkTemplate($template, Tag $tag = null) { if ($this->disabled) { return; } if (!isset($tag)) { $tag = new Tag; } // Load the template into a DOMDocument $dom = TemplateLoader::load($template); foreach ($this->collection as $check) { $check->check($dom->documentElement, $tag); } } /** * Disable all checks * * @deprecated 2.2.0 Use UnsafeTemplate instead * * @return void */ public function disable() { $this->disabled = true; } /** * Enable all checks * * @deprecated 2.2.0 * * @return void */ public function enable() { $this->disabled = false; } }