Changeset 65c3bb0 in github


Ignore:
Timestamp:
Jun 13, 2012 9:07:46 AM (11 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
release-0.8
Children:
d5d3c70
Parents:
21be272
Message:

Fix handling of unitless CSS size values in HTML message (#1488535)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r21be272 r65c3bb0  
    22=========================== 
    33 
     4- Fix handling of unitless CSS size values in HTML message (#1488535) 
    45- Fix removing contact photo using LDAP addressbook (#1488420) 
    56- Fix storing X-ANNIVERSARY date in vCard format (#1488527) 
  • program/lib/washtml.php

    r51809bd r65c3bb0  
    7777 * - base URL support 
    7878 * - invalid HTML comments removal before parsing 
     79 * - "fixing" unitless CSS values for XHTML output 
    7980 */ 
    8081 
     
    158159      if (preg_match('/^\s*([a-z\-]+)\s*:\s*(.*)\s*$/i', $declaration, $match)) { 
    159160        $cssid = $match[1]; 
    160         $str = $match[2]; 
     161        $str   = $match[2]; 
    161162        $value = ''; 
     163 
    162164        while (sizeof($str) > 0 && 
    163165          preg_match('/^(url\(\s*[\'"]?([^\'"\)]*)[\'"]?\s*\)'./*1,2*/ 
    164166                 '|rgb\(\s*[0-9]+\s*,\s*[0-9]+\s*,\s*[0-9]+\s*\)'. 
    165167                 '|-?[0-9.]+\s*(em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)?'. 
    166                  '|#[0-9a-f]{3,6}|[a-z0-9", -]+'. 
    167                  ')\s*/i', $str, $match)) { 
     168                 '|#[0-9a-f]{3,6}'. 
     169                 '|[a-z0-9", -]+'. 
     170                 ')\s*/i', $str, $match) 
     171        ) { 
    168172          if ($match[2]) { 
    169173            if (($src = $this->config['cid_map'][$match[2]]) 
     
    181185            } 
    182186          } 
    183           else if ($match[0] != 'url' && $match[0] != 'rgb') //whitelist ? 
     187          else { //whitelist ? 
    184188            $value .= ' ' . $match[0]; 
    185189 
     190            // #1488535: Fix size units, so width:800 would be changed to width:800px 
     191            if (preg_match('/(left|right|top|bottom|width|height)/i', $cssid) && preg_match('/^[0-9]+$/', $match[0])) { 
     192              $value .= 'px'; 
     193            } 
     194          } 
     195 
    186196          $str = substr($str, strlen($match[0])); 
    187197        } 
    188         if ($value) 
     198 
     199        if (isset($value[0])) { 
    189200          $s .= ($s?' ':'') . $cssid . ':' . $value . ';'; 
     201        } 
    190202      } 
    191203    } 
Note: See TracChangeset for help on using the changeset viewer.