Changeset a1013c0 in github


Ignore:
Timestamp:
Jan 10, 2011 9:50:48 AM (2 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
00e18b7
Parents:
0ff554d
Message:

Exclude punctuation from URLs within text; only link accepted url schemes

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_string_replacer.php

    r0ff554d ra1013c0  
    3838    // Simplified domain expression for UTF8 characters handling 
    3939    $utf_domain = '[^?&@"\'\\/()\s\r\t\n]+\\.[a-z]{2,5}'; 
    40     $url = '[a-z0-9%=#@+?.:;&\\/_~\\[\\]-]+'; 
     40    $url1 = '.:;'; 
     41    $url2 = 'a-z0-9%=#@+?&\\/_~\\[\\]-'; 
    4142 
    42     $this->link_pattern = "/([\w]+:\/\/|\Wwww\.)($utf_domain($url)?)/i"; 
     43    $this->link_pattern = "/([\w]+:\/\/|\Wwww\.)($utf_domain([$url1]?[$url2]+)*)/i"; 
    4344    $this->mailto_pattern = "/(" 
    4445        ."[-\w!\#\$%&\'*+~\/^`|{}=]+(?:\.[-\w!\#\$%&\'*+~\/^`|{}=]+)*"  // local-part 
    4546        ."@$utf_domain"                                                 // domain-part 
    46         ."(\?$url)?"                                                    // e.g. ?subject=test... 
     47        ."(\?[$url1$url2]+)?"                                           // e.g. ?subject=test... 
    4748        .")/i"; 
    4849  } 
     
    8990    } 
    9091 
    91     $suffix = $this->parse_url_brackets($url); 
    92     $i = $this->add($prefix . html::a(array( 
    93       'href' => $url_prefix . $url, 
    94       'target' => '_blank' 
    95       ), Q($url)) . $suffix); 
     92    if ($url) { 
     93      $suffix = $this->parse_url_brackets($url); 
     94      $i = $this->add($prefix . html::a(array( 
     95          'href' => $url_prefix . $url, 
     96          'target' => '_blank' 
     97        ), Q($url)) . $suffix); 
     98    } 
    9699 
    97100    // Return valid link for recognized schemes, otherwise, return the unmodified string for unrecognized schemes. 
  • tests/mailfunc.php

    r0ff554d ra1013c0  
    113113 
    114114    $this->assertPattern('/<a href="mailto:nobody@roundcube.net" onclick="return rcmail.command\(\'compose\',\'nobody@roundcube.net\',this\)">nobody@roundcube.net<\/a>/', $html, "Mailto links with onclick"); 
    115     $this->assertPattern('#<a href="http://www.apple.com/legal/privacy/" target="_blank">http://www.apple.com/legal/privacy/</a>#', $html, "Links with target=_blank"); 
     115    $this->assertPattern('#<a href="http://www.apple.com/legal/privacy" target="_blank">http://www.apple.com/legal/privacy</a>#', $html, "Links with target=_blank"); 
    116116    $this->assertPattern('#\\[<a href="http://example.com/\\?tx\\[a\\]=5" target="_blank">http://example.com/\\?tx\\[a\\]=5</a>\\]#', $html, "Links with square brackets"); 
    117117  } 
  • tests/src/plainbody.txt

    r0ff554d ra1013c0  
    3131 
    3232Privacy Policy 
    33 http://www.apple.com/legal/privacy/ 
     33http://www.apple.com/legal/privacy. 
    3434 
    3535My Info 
Note: See TracChangeset for help on using the changeset viewer.