Horde_Text_Filter_Linkurls::decode PHP Method

decode() public static method

"Decodes" the text formerly encoded by using the "encode" parameter.
public static decode ( string $text ) : string
$text string An encoded text.
return string The decoded text.
    public static function decode($text)
    {
        return preg_replace_callback('/\\00\\00\\00([\\w=+\\/]*)\\00\\00\\00/', function ($hex) {
            return base64_decode($hex[1]);
        }, $text);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Parse the information in mailing list headers.
  *
  * @param string $id    The header ID.
  * @param string $data  The header text to process.
  *
  * @return string  The HTML-escaped header value.
  */
 protected function _parseListHeaders($id, $data)
 {
     global $injector;
     $parser = $injector->getInstance('Horde_ListHeaders');
     $text_filter = $injector->getInstance('Horde_Core_Factory_TextFilter');
     $parsed = $parser->parse($id, $data);
     if ($parsed instanceof Horde_ListHeaders_Id) {
         $out = $parsed->id;
         if ($parsed->label) {
             $out .= ' -- <em>' . $parsed->label . '</em>';
         }
         return $out;
     }
     foreach ($parsed as $val) {
         /* RFC 2369 [2] states that we should only show the *FIRST* URL
          * that appears in a header that we can adequately handle. */
         if (stripos($val->url, 'mailto:') === 0) {
             $url = substr($val->url, 7);
             $clink = new IMP_Compose_Link($url);
             $out = Horde::link($clink->link()) . $url . '</a>';
             foreach ($val->comments as $val2) {
                 $out .= htmlspecialchars('(' . $val2 . ')');
             }
             return $out;
         } elseif ($url = $text_filter->filter($val->url, 'Linkurls')) {
             $out = $url;
             foreach ($val->comments as $val2) {
                 $out .= htmlspecialchars('(' . $val2 . ')');
             }
             return $out;
         }
     }
     /* Pass through Linkurls filter anyway, since it is possible the
      * sender did not correctly put URL between brackets. */
     return Horde_Text_Filter_Linkurls::decode(htmlspecialchars($text_filter->filter($data, 'Linkurls', array('encode' => true))));
 }
All Usage Examples Of Horde_Text_Filter_Linkurls::decode