Changeset 9082bf1 in github for program/lib/washtml.php


Ignore:
Timestamp:
May 12, 2012 5:27:59 AM (13 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo
Children:
1c9e571
Parents:
4abcbd4
Message:

Fix handling of some HTML tags e.g. IMG (#1488471) - reworked fix for #1486812

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/lib/washtml.php

    rf38dfc29 r9082bf1  
    109109  /* Block elements which could be empty but cannot be returned in short form (<tag />) */ 
    110110  static $block_elements = array('div', 'p', 'pre', 'blockquote', 'a', 'font', 'center', 
    111     'table', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'dl', 'strong', 'i', 'b', 'u'); 
     111    'table', 'ul', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'dl', 'strong', 'i', 'b', 'u', 'span'); 
    112112 
    113113  /* State for linked objects in HTML */ 
     
    134134 
    135135  /* Constructor */ 
    136   public function __construct($p = array()) { 
     136  public function __construct($p = array()) 
     137  { 
    137138    $this->_html_elements = array_flip((array)$p['html_elements']) + array_flip(self::$html_elements) ; 
    138139    $this->_html_attribs = array_flip((array)$p['html_attribs']) + array_flip(self::$html_attribs); 
     
    150151 
    151152  /* Check CSS style */ 
    152   private function wash_style($style) { 
     153  private function wash_style($style) 
     154  { 
    153155    $s = ''; 
    154156 
     
    192194 
    193195  /* Take a node and return allowed attributes and check values */ 
    194   private function wash_attribs($node) { 
     196  private function wash_attribs($node) 
     197  { 
    195198    $t = ''; 
    196199    $washed; 
     
    232235   * It output only allowed tags with allowed attributes 
    233236   * and allowed inline styles */ 
    234   private function dumpHtml($node) { 
     237  private function dumpHtml($node) 
     238  { 
    235239    if(!$node->hasChildNodes()) 
    236240      return ''; 
     
    249253          $content = $this->dumpHtml($node); 
    250254          $dump .= '<' . $tagName . $this->wash_attribs($node) . 
    251             // create closing tag for block elements, but also for elements 
    252             // with content or with some attributes (eg. style, class) (#1486812) 
    253             ($content != '' || $node->hasAttributes() || isset($this->_block_elements[$tagName]) ? ">$content</$tagName>" : ' />'); 
     255            ($content != '' || isset($this->_block_elements[$tagName]) ? ">$content</$tagName>" : ' />'); 
    254256        } 
    255257        else if (isset($this->_ignore_elements[$tagName])) { 
     
    311313 
    312314} 
    313  
    314 ?> 
Note: See TracChangeset for help on using the changeset viewer.