46 $this->target = $config->get(
'URI.' . $this->name);
48 $this->doEmbed = $config->get(
'URI.MungeResources');
49 $this->secretKey = $config->get(
'URI.MungeSecretKey');
50 if ($this->secretKey && !function_exists(
'hash_hmac')) {
51 throw new Exception(
"Cannot use %URI.MungeSecretKey without hash_hmac support.");
62 public function filter(&$uri, $config, $context)
68 $scheme_obj = $uri->getSchemeObj($config, $context);
72 if (!$scheme_obj->browsable) {
75 if ($uri->isBenign($config, $context)) {
80 $this->replace = array_map(
'rawurlencode', $this->replace);
82 $new_uri = strtr($this->target, $this->replace);
83 $new_uri = $this->parser->parse($new_uri);
86 if ($uri->host === $new_uri->host) {
100 $string = $uri->toString();
102 $this->replace[
'%s'] = $string;
103 $this->replace[
'%r'] = $context->get(
'EmbeddedURI',
true);
104 $token = $context->get(
'CurrentToken',
true);
105 $this->replace[
'%n'] = $token ? $token->name : null;
106 $this->replace[
'%m'] = $context->get(
'CurrentAttr',
true);
107 $this->replace[
'%p'] = $context->get(
'CurrentCSSProperty',
true);
109 if ($this->secretKey) {
110 $this->replace[
'%t'] = hash_hmac(
"sha256", $string, $this->secretKey);