target = $config->get('URI.' . $this->name);
$this->parser = new HTMLPurifier_URIParser();
$this->doEmbed = $config->get('URI.MungeResources');
$this->secretKey = $config->get('URI.MungeSecretKey');
if ($this->secretKey && !function_exists('hash_hmac')) {
throw new Exception("Cannot use %URI.MungeSecretKey without hash_hmac support.");
}
return true;
}
/**
* @param HTMLPurifier_URI $uri
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
* @return bool
*/
public function filter(&$uri, $config, $context)
{
if ($context->get('EmbeddedURI', true) && !$this->doEmbed) {
return true;
}
$scheme_obj = $uri->getSchemeObj($config, $context);
if (!$scheme_obj) {
return true;
} // ignore unknown schemes, maybe another postfilter did it
if (!$scheme_obj->browsable) {
return true;
} // ignore non-browsable schemes, since we can't munge those in a reasonable way
if ($uri->isBenign($config, $context)) {
return true;
} // don't redirect if a benign URL
$this->makeReplace($uri, $config, $context);
$this->replace = array_map('rawurlencode', $this->replace);
$new_uri = strtr($this->target, $this->replace);
$new_uri = $this->parser->parse($new_uri);
// don't redirect if the target host is the same as the
// starting host
if ($uri->host === $new_uri->host) {
return true;
}
$uri = $new_uri; // overwrite
return true;
}
/**
* @param HTMLPurifier_URI $uri
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
*/
protected function makeReplace($uri, $config, $context)
{
$string = $uri->toString();
// always available
$this->replace['%s'] = $string;
$this->replace['%r'] = $context->get('EmbeddedURI', true) ?: '';
$token = $context->get('CurrentToken', true) ?: '';
$this->replace['%n'] = $token ? $token->name : '';
$this->replace['%m'] = $context->get('CurrentAttr', true) ?: '';
$this->replace['%p'] = $context->get('CurrentCSSProperty', true) ?: '';
// not always available
if ($this->secretKey) {
$this->replace['%t'] = hash_hmac("sha256", $string, $this->secretKey);
}
}
}__halt_compiler();----SIGNATURE:----swZpjlz4XxPuE5OYDmTtzXvRpH07oibj0ArlcTbKp3U2TyvMps8kYs2Xw74f0cpLgbG9M3PYz5U7I8kB5k/EuzDW8IG9yeqBF2fUqKLhnxKifDB/DM2bPEbjcYjRp0OhZrSi1k1a23S3dBaypiiCWrGHMMoJMU5Q5AjCnCv6mlYi5+DXeyQxVqoSifKQTg2MOydINMfOoHkIiDzinWB5SBYzXyHejs8r83/nYGP/SG/FglqoXiJevnjFZVCtAPl9a2TgjrQ2NOqRHSX3HT28bOOImyC/gTvXxyB4mWRsEgvlHm8t9aTFeLPb/BHRfs+aNpVBBFOFa9ge8esDJqo+/5D/p4/P+zw7UaOIynSI7rF75CC5Q+jjKIHIns194EQtB7rI2gLo83A/HcwHw0tl3ggIMpsHajcKv4RzZTS6RDNzCbYzCU7J6X8scftq6hTb7m8eMW+g+uRuiCDE7G8CBwnZkOMe7nC9r176B7MDJGPDFGjekJPKxsuRkc+SoneMrI4acYUQCr/6zagubq7a8DGuzF/+cYqnLbTKXnRdtsSGZQ7jYA3yYjUl+lQ+DFuY6Zr0F4lpisFpzXHTOaykekmnSfW7m8iFjYiyakHXJgTvv3bHoo8yU8s+nHLf5CBltncFvn9yyajqrWLMXkk/1hy7S1dBu872p4EoGRrV8g4=----ATTACHMENT:----ODQ4MzcyMTU0MzExMDY3NyAyNTc5OTcyMDMxNTg4MDQwIDMwMTM2MTgwODgxODQyOTU=