Пример #1
0
 /**
  */
 public function callback($match)
 {
     $href = $orig_href = $match[0];
     if (strpos($match[2], ':') === false) {
         $href = 'http://' . $href;
     }
     if ($this->_params['callback']) {
         $href = call_user_func($this->_params['callback'], $href);
     }
     $href = htmlspecialchars($href);
     $class = $this->_params['class'];
     if (!empty($class)) {
         $class = ' class="' . $class . '"';
     }
     $target = $this->_params['target'];
     if (!empty($target)) {
         $target = ' target="' . $target . '"';
     }
     $decoded = $orig_href;
     try {
         if (strlen($host = $this->_parseurl($orig_href, PHP_URL_HOST))) {
             $decoded = substr_replace($orig_href, Horde_Idna::decode($host), strpos($orig_href, $host), strlen($host));
         }
     } catch (Horde_Idna_Exception $e) {
     } catch (InvalidArgumentException $e) {
     }
     $replacement = '<a href="' . $href . '"' . ($this->_params['nofollow'] ? ' rel="nofollow"' : '') . $target . $class . '>' . htmlspecialchars($decoded) . '</a>';
     if (!empty($this->_params['noprefetch'])) {
         $replacement = '<meta http-equiv="x-dns-prefetch-control" value="off" />' . $replacement . '<meta http-equiv="x-dns-prefetch-control" value="on" />';
     }
     if ($this->_params['encode']) {
         $replacement = chr(0) . chr(0) . chr(0) . base64_encode($replacement) . chr(0) . chr(0) . chr(0);
     }
     return $replacement;
 }
Пример #2
0
 /**
  */
 public function __set($name, $value)
 {
     switch ($name) {
         case 'host':
             try {
                 $value = Horde_Idna::decode($value);
             } catch (Horde_Idna_Exception $e) {
             }
             $this->_host = Horde_String::lower($value);
             break;
         case 'personal':
             $this->_personal = strlen($value) ? Horde_Mime::decode($value) : null;
             break;
     }
 }
Пример #3
0
 /**
  * @dataProvider domainNamesProvider
  */
 public function testDecode($decoded, $encoded)
 {
     $idna = new Horde_Idna();
     $this->assertEquals($decoded, $idna->decode($encoded));
 }