Changeset 5430 in subversion


Ignore:
Timestamp:
Nov 15, 2011 11:47:40 AM (19 months ago)
Author:
alec
Message:
  • Fix washing styles with quoted values e.g. font-family
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/lib/washtml.php

    r5428 r5430  
    142142    $this->config = $p + array('show_washed'=>true, 'allow_remote'=>false, 'cid_map'=>array()); 
    143143  } 
    144    
     144 
    145145  /* Register a callback function for a certain tag */ 
    146146  public function add_callback($tagName, $callback) 
     
    148148    $this->handlers[$tagName] = $callback; 
    149149  } 
    150    
     150 
    151151  /* Check CSS style */ 
    152152  private function wash_style($style) { 
     
    162162                 '|rgb\(\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*\)'. 
    163163                 '|-?[0-9.]+\s*(em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)?'. 
    164                  '|#[0-9a-f]{3,6}|[a-z0-9\-]+'. 
     164                 '|#[0-9a-f]{3,6}|[a-z0-9", -]+'. 
    165165                 ')\s*/i', $str, $match)) { 
    166166          if ($match[2]) { 
     
    179179            } 
    180180          } 
    181           else if ($match[0] != 'url' && $match[0] != 'rbg') //whitelist ? 
     181          else if ($match[0] != 'url' && $match[0] != 'rgb') //whitelist ? 
    182182            $value .= ' ' . $match[0]; 
     183 
    183184          $str = substr($str, strlen($match[0])); 
    184185        } 
     
    201202         ($key == 'href' && preg_match('/^(http:|https:|ftp:|mailto:|#).+/i', $value))) 
    202203        $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 
    203       else if ($key == 'style' && ($style = $this->wash_style($value))) 
    204         $t .= ' style="' . $style . '"'; 
     204      else if ($key == 'style' && ($style = $this->wash_style($value))) { 
     205        $quot = strpos($style, '"') !== false ? "'" : '"'; 
     206        $t .= ' style=' . $quot . $style . $quot; 
     207      } 
    205208      else if ($key == 'background' || ($key == 'src' && strtolower($node->tagName) == 'img')) { //check tagName anyway 
    206209        if (($src = $this->config['cid_map'][$value]) 
Note: See TracChangeset for help on using the changeset viewer.