Changeset 51809bd in github
- Timestamp:
- Jun 8, 2012 2:59:10 AM (12 months ago)
- Branches:
- release-0.8
- Children:
- a7d5e3e8
- Parents:
- 49db523
- git-author:
- Aleksander Machniak <alec@…> (06/08/12 02:53:07)
- git-committer:
- Aleksander Machniak <alec@…> (06/08/12 02:59:10)
- Files:
-
- 3 edited
-
CHANGELOG (modified) (1 diff)
-
program/lib/html2text.php (modified) (6 diffs)
-
program/lib/washtml.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r0e58211 r51809bd 2 2 =========================== 3 3 4 - Fix handling of links with various URI schemes e.g. "skype:" (#1488106) 5 - Fix handling of links inside PRE elements on html to text conversion 6 - Fix indexing of links on html to text conversion 4 7 - Decode header value in rcube_mime::get() by default (#1488511) 5 8 - Fix errors with enabled PHP magic_quotes_sybase option (#1488506) -
program/lib/html2text.php
rb4a0b92 r51809bd 250 250 */ 251 251 var $callback_search = array( 252 '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i', 253 // <a href=""> 254 '/<(h)[123456][^>]*>(.*?)<\/h[123456]>/i', // H1 - H3 255 '/<(b)[^>]*>(.*?)<\/b>/i', // <b> 256 '/<(strong)[^>]*>(.*?)<\/strong>/i', // <strong> 257 '/<(th)[^>]*>(.*?)<\/th>/i', // <th> and </th> 252 '/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i', // <a href=""> 253 '/<(h)[123456]( [^>]*)?>(.*?)<\/h[123456]>/i', // h1 - h6 254 '/<(b)( [^>]*)?>(.*?)<\/b>/i', // <b> 255 '/<(strong)( [^>]*)?>(.*?)<\/strong>/i', // <strong> 256 '/<(th)( [^>]*)?>(.*?)<\/th>/i', // <th> and </th> 258 257 ); 259 258 … … 369 368 { 370 369 if ( $from_file && file_exists($source) ) { 371 $this->html = file_get_contents($source); 370 $this->html = file_get_contents($source); 372 371 } 373 372 else … … 561 560 562 561 // Ignored link types 563 if (preg_match('!^(javascript |mailto|#):!i', $link)) {562 if (preg_match('!^(javascript:|mailto:|#)!i', $link)) { 564 563 return $display; 565 564 } 566 565 567 if (preg_match('!^( https?://)!i', $link)) {566 if (preg_match('!^([a-z][a-z0-9.+-]+:)!i', $link)) { 568 567 $url = $link; 569 568 } … … 577 576 578 577 if (($index = array_search($url, $this->_link_list)) === false) { 578 $index = count($this->_link_list); 579 579 $this->_link_list[] = $url; 580 $index = count($this->_link_list);581 580 } 582 581 … … 594 593 // get the content of PRE element 595 594 while (preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) { 595 $this->pre_content = $matches[1]; 596 597 // Run our defined tags search-and-replace with callback 598 $this->pre_content = preg_replace_callback($this->callback_search, 599 array('html2text', '_preg_callback'), $this->pre_content); 600 596 601 // convert the content 597 602 $this->pre_content = sprintf('<div><br>%s<br></div>', 598 preg_replace($this->pre_search, $this->pre_replace, $matches[1])); 603 preg_replace($this->pre_search, $this->pre_replace, $this->pre_content)); 604 599 605 // replace the content (use callback because content can contain $0 variable) 600 $text = preg_replace_callback('/<pre[^>]*>.*<\/pre>/ismU', 606 $text = preg_replace_callback('/<pre[^>]*>.*<\/pre>/ismU', 601 607 array('html2text', '_preg_pre_callback'), $text, 1); 608 602 609 // free memory 603 610 $this->pre_content = ''; … … 672 679 case 'b': 673 680 case 'strong': 674 return $this->_toupper($matches[ 2]);681 return $this->_toupper($matches[3]); 675 682 case 'th': 676 return $this->_toupper("\t\t". $matches[ 2] ."\n");683 return $this->_toupper("\t\t". $matches[3] ."\n"); 677 684 case 'h': 678 return $this->_toupper("\n\n". $matches[ 2] ."\n\n");685 return $this->_toupper("\n\n". $matches[3] ."\n\n"); 679 686 case 'a': 680 687 // Remove spaces in URL (#1487805) -
program/lib/washtml.php
r02cf44e r51809bd 203 203 $value = $node->getAttribute($key); 204 204 if (isset($this->_html_attribs[$key]) || 205 ($key == 'href' && preg_match('!^( http:|https:|ftp:|mailto:|//|#).+!i', $value)))205 ($key == 'href' && preg_match('!^([a-z][a-z0-9.+-]+:|//|#).+!i', $value))) 206 206 $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 207 207 else if ($key == 'style' && ($style = $this->wash_style($value))) {
Note: See TracChangeset
for help on using the changeset viewer.
