Changeset 5862 in subversion


Ignore:
Timestamp:
Feb 8, 2012 6:58:33 AM (17 months ago)
Author:
alec
Message:
  • Improved r5861 change: Content converted to upper case can contain HTML tags, handle them properly
File:
1 edited

Legend:

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

    r5861 r5862  
    250250     */ 
    251251    var $callback_search = array( 
     252        '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i', 
     253                                                   // <a href=""> 
    252254        '/<(h)[123456][^>]*>(.*?)<\/h[123456]>/i', // H1 - H3 
    253255        '/<(b)[^>]*>(.*?)<\/b>/i',                 // <b> 
    254256        '/<(strong)[^>]*>(.*?)<\/strong>/i',       // <strong> 
    255         '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i', 
    256                                                    // <a href=""> 
    257257        '/<(th)[^>]*>(.*?)<\/th>/i',               // <th> and </th> 
    258258    ); 
     
    676676        case 'b': 
    677677        case 'strong': 
    678             return $this->_strtoupper($matches[2]); 
     678            return $this->_toupper($matches[2]); 
    679679        case 'th': 
    680             return $this->_strtoupper("\t\t". $matches[2] ."\n"); 
     680            return $this->_toupper("\t\t". $matches[2] ."\n"); 
    681681        case 'h': 
    682             return $this->_strtoupper("\n\n". $matches[2] ."\n\n"); 
     682            return $this->_toupper("\n\n". $matches[2] ."\n\n"); 
    683683        case 'a': 
    684684            // Remove spaces in URL (#1487805) 
     
    700700 
    701701    /** 
    702      *  Strtoupper multibyte wrapper function with HTML entities handling 
    703      * 
    704      *  @param string $str Text to convert 
    705      *  @return string Converted text 
     702     * Strtoupper function with HTML tags and entities handling. 
     703     * 
     704     * @param string $str Text to convert 
     705     * @return string Converted text 
     706     */ 
     707    private function _toupper($str) 
     708    { 
     709        // string can containg HTML tags 
     710        $chunks = preg_split('/(<[^>]*>)/', $str, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); 
     711 
     712        // convert toupper only the text between HTML tags 
     713        foreach ($chunks as $idx => $chunk) { 
     714            if ($chunk[0] != '<') { 
     715                $chunks[$idx] = $this->_strtoupper($chunk); 
     716            } 
     717        } 
     718 
     719        return implode($chunks); 
     720    } 
     721 
     722    /** 
     723     * Strtoupper multibyte wrapper function with HTML entities handling. 
     724     * 
     725     * @param string $str Text to convert 
     726     * @return string Converted text 
    706727     */ 
    707728    private function _strtoupper($str) 
Note: See TracChangeset for help on using the changeset viewer.