Make WordPress Core

Changeset 17570


Ignore:
Timestamp:
03/28/2011 09:39:16 PM (14 years ago)
Author:
ryan
Message:

Reduce backtracking in make_clickable() regex. Reduce pcre.recursion_limit to avoid segfaulting. Props hakre. For trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r17459 r17570  
    13871387    $ret = ' ' . $ret;
    13881388    // in testing, using arrays here was found to be faster
    1389     $ret = preg_replace_callback('#(?<!=[\'"])(?<=[*\')+.,;:!&$\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
     1389    $save = @ini_set('pcre.recursion_limit', 10000);
     1390    $retval = preg_replace_callback('#(?<!=[\'"])(?<=[*\')+.,;:!&$\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#%~/?@\[\]-]{1,2000}|[\'*(+.,;:!=&$](?![\b\)]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
     1391    if (null !== $retval )
     1392        $ret = $retval;
     1393    @ini_set('pcre.recursion_limit', $save);
    13901394    $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
    13911395    $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
Note: See TracChangeset for help on using the changeset viewer.