Changeset 3651 in subversion


Ignore:
Timestamp:
May 22, 2010 3:27:15 AM (3 years ago)
Author:
alec
Message:
  • Add support for data URI scheme [RFC2397] (#1486740)
Location:
trunk/roundcubemail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r3650 r3651  
    22=========================== 
    33 
     4- Add support for data URI scheme [RFC2397] (#1486740) 
    45- Added 'actionbefore', 'actionafter', 'responsebefore', 'responseafter' events 
    56- Removed response.callbacks feature 
  • trunk/roundcubemail/program/lib/washtml.php

    r3521 r3651  
    7474 * - added $block_elements 
    7575 * - changed $ignore_elements behaviour 
     76 * - added RFC2397 support 
    7677 */ 
    7778 
     
    132133    $s = ''; 
    133134 
    134     foreach(explode(';', $style) as $declaration) { 
    135       if(preg_match('/^\s*([a-z\-]+)\s*:\s*(.*)\s*$/i', $declaration, $match)) { 
     135    foreach (explode(';', $style) as $declaration) { 
     136      if (preg_match('/^\s*([a-z\-]+)\s*:\s*(.*)\s*$/i', $declaration, $match)) { 
    136137        $cssid = $match[1]; 
    137138        $str = $match[2]; 
    138139        $value = ''; 
    139         while(sizeof($str) > 0 && 
     140        while (sizeof($str) > 0 && 
    140141          preg_match('/^(url\(\s*[\'"]?([^\'"\)]*)[\'"]?\s*\)'./*1,2*/ 
    141142                 '|rgb\(\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*\)'. 
     
    143144                 '|#[0-9a-f]{3,6}|[a-z0-9\-]+'. 
    144145                 ')\s*/i', $str, $match)) { 
    145           if($match[2]) { 
    146             if($src = $this->config['cid_map'][$match[2]]) 
    147               $value .= ' url(\''.htmlspecialchars($src, ENT_QUOTES) . '\')'; 
    148             else if(preg_match('/^(http|https|ftp):.*$/i', $match[2], $url)) { 
    149               if($this->config['allow_remote']) 
    150                 $value .= ' url(\''.htmlspecialchars($url[0], ENT_QUOTES).'\')'; 
     146          if ($match[2]) { 
     147            if ($src = $this->config['cid_map'][$match[2]]) 
     148              $value .= ' url('.htmlspecialchars($src, ENT_QUOTES) . ')'; 
     149            else if (preg_match('/^(http|https|ftp):.*$/i', $match[2], $url)) { 
     150              if ($this->config['allow_remote']) 
     151                $value .= ' url('.htmlspecialchars($url[0], ENT_QUOTES).')'; 
    151152              else 
    152153                $this->extlinks = true; 
    153154            } 
    154           } else if($match[0] != 'url' && $match[0] != 'rbg')//whitelist ? 
     155            else if (preg_match('/^data:.+/i', $url)) { // RFC2397 
     156              $value .= ' url('.htmlspecialchars($url, ENT_QUOTES).')'; 
     157            } 
     158          } else if ($match[0] != 'url' && $match[0] != 'rbg') //whitelist ? 
    155159            $value .= ' ' . $match[0]; 
    156160          $str = substr($str, strlen($match[0])); 
    157161        } 
    158         if($value) 
     162        if ($value) 
    159163          $s .= ($s?' ':'') . $cssid . ':' . $value . ';'; 
    160164      } 
     
    168172    $washed; 
    169173 
    170     foreach($node->attributes as $key => $plop) { 
     174    foreach ($node->attributes as $key => $plop) { 
    171175      $key = strtolower($key); 
    172176      $value = $node->getAttribute($key); 
    173       if(isset($this->_html_attribs[$key]) || 
     177      if (isset($this->_html_attribs[$key]) || 
    174178         ($key == 'href' && preg_match('/^(http:|https:|ftp:|mailto:|#).+/i', $value))) 
    175179        $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 
    176       else if($key == 'style' && ($style = $this->wash_style($value))) 
     180      else if ($key == 'style' && ($style = $this->wash_style($value))) 
    177181        $t .= ' style="' . $style . '"'; 
    178       else if($key == 'background' || ($key == 'src' && strtolower($node->tagName) == 'img')) { //check tagName anyway 
    179         if($src = $this->config['cid_map'][$value]) { 
     182      else if ($key == 'background' || ($key == 'src' && strtolower($node->tagName) == 'img')) { //check tagName anyway 
     183        if ($src = $this->config['cid_map'][$value]) { 
    180184          $t .= ' ' . $key . '="' . htmlspecialchars($src, ENT_QUOTES) . '"'; 
    181185        } 
    182         else if(preg_match('/^(http|https|ftp):.+/i', $value)) { 
    183           if($this->config['allow_remote']) 
     186        else if (preg_match('/^(http|https|ftp):.+/i', $value)) { 
     187          if ($this->config['allow_remote']) 
    184188            $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 
    185189          else { 
     
    188192              $t .= ' ' . $key . '="' . htmlspecialchars($this->config['blocked_src'], ENT_QUOTES) . '"'; 
    189193          } 
     194        } 
     195        else if (preg_match('/^data:.+/i', $value)) { // RFC2397 
     196          $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 
    190197        } 
    191198      } else 
Note: See TracChangeset for help on using the changeset viewer.