aboutsummaryrefslogtreecommitdiffstats
path: root/library/HTMLPurifier/URIDefinition.php
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2015-01-06 15:13:03 +0100
committermrjive <mrjive@mrjive.it>2015-01-06 15:13:03 +0100
commitb80c218606994032e76805900cb9b340ea132358 (patch)
treebf625cf4c59bf521e639018399bf1770d116a6a0 /library/HTMLPurifier/URIDefinition.php
parentaa6d61d3b19cb13c30bf5a1579adefedf0cc9515 (diff)
parent3185bfe3ca131d471b8fcdc0c94abf1a114486c7 (diff)
downloadvolse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.gz
volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.tar.bz2
volse-hubzilla-b80c218606994032e76805900cb9b340ea132358.zip
Merge pull request #1 from friendica/master
test pull request
Diffstat (limited to 'library/HTMLPurifier/URIDefinition.php')
-rw-r--r--library/HTMLPurifier/URIDefinition.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/library/HTMLPurifier/URIDefinition.php b/library/HTMLPurifier/URIDefinition.php
index ea2b8fe24..e0bd8bcca 100644
--- a/library/HTMLPurifier/URIDefinition.php
+++ b/library/HTMLPurifier/URIDefinition.php
@@ -23,19 +23,24 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
*/
public $defaultScheme;
- public function __construct() {
+ public function __construct()
+ {
$this->registerFilter(new HTMLPurifier_URIFilter_DisableExternal());
$this->registerFilter(new HTMLPurifier_URIFilter_DisableExternalResources());
+ $this->registerFilter(new HTMLPurifier_URIFilter_DisableResources());
$this->registerFilter(new HTMLPurifier_URIFilter_HostBlacklist());
+ $this->registerFilter(new HTMLPurifier_URIFilter_SafeIframe());
$this->registerFilter(new HTMLPurifier_URIFilter_MakeAbsolute());
$this->registerFilter(new HTMLPurifier_URIFilter_Munge());
}
- public function registerFilter($filter) {
+ public function registerFilter($filter)
+ {
$this->registeredFilters[$filter->name] = $filter;
}
- public function addFilter($filter, $config) {
+ public function addFilter($filter, $config)
+ {
$r = $filter->prepare($config);
if ($r === false) return; // null is ok, for backwards compat
if ($filter->post) {
@@ -45,22 +50,29 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
}
}
- protected function doSetup($config) {
+ protected function doSetup($config)
+ {
$this->setupMemberVariables($config);
$this->setupFilters($config);
}
- protected function setupFilters($config) {
+ protected function setupFilters($config)
+ {
foreach ($this->registeredFilters as $name => $filter) {
- $conf = $config->get('URI.' . $name);
- if ($conf !== false && $conf !== null) {
+ if ($filter->always_load) {
$this->addFilter($filter, $config);
+ } else {
+ $conf = $config->get('URI.' . $name);
+ if ($conf !== false && $conf !== null) {
+ $this->addFilter($filter, $config);
+ }
}
}
unset($this->registeredFilters);
}
- protected function setupMemberVariables($config) {
+ protected function setupMemberVariables($config)
+ {
$this->host = $config->get('URI.Host');
$base_uri = $config->get('URI.Base');
if (!is_null($base_uri)) {
@@ -72,7 +84,13 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI.DefaultScheme');
}
- public function filter(&$uri, $config, $context) {
+ public function getDefaultScheme($config, $context)
+ {
+ return HTMLPurifier_URISchemeRegistry::instance()->getScheme($this->defaultScheme, $config, $context);
+ }
+
+ public function filter(&$uri, $config, $context)
+ {
foreach ($this->filters as $name => $f) {
$result = $f->filter($uri, $config, $context);
if (!$result) return false;
@@ -80,7 +98,8 @@ class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition
return true;
}
- public function postFilter(&$uri, $config, $context) {
+ public function postFilter(&$uri, $config, $context)
+ {
foreach ($this->postFilters as $name => $f) {
$result = $f->filter($uri, $config, $context);
if (!$result) return false;