[wp-trac] [WordPress Trac] #8986: Regular expression syntax errors
- missing preg pattern delimiters
WordPress Trac
wp-trac at lists.automattic.com
Thu Jan 29 07:14:34 GMT 2009
#8986: Regular expression syntax errors - missing preg pattern delimiters
--------------------------+-------------------------------------------------
Reporter: ridgerunner | Owner: anonymous
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.8
Component: General | Version: 2.7
Severity: normal | Keywords: regex preg
--------------------------+-------------------------------------------------
I am a regex guy looking into maybe using wp. While scanning your wp code
(specifically the preg_*() calls), I found three typo's (i.e. regex
pattern strings having unintended/missing delimiters) that you may wish to
clean up. All three regexs are simple character classes that are not
behaving as intended, because the opening and closing square brackets are
unintentionally being stripped out as the pattern delimiters (i.e. the as-
written preg_replace() pattern: '[class]' should instead be written as:
'/[class]/', or '#[class]#', or '{[class]}', etc.).
{{{
file: wordpress-2.7\wp-includes\class-phpmailer.php
line: 1412
current: $encoded = preg_replace("[\r\n]", '', $str);
fixed: $encoded = preg_replace("/[\r\n]/", '', $str);
file: wordpress-2.7\wp-includes\formatting.php
line: 1773
current: $safe_tag = strtolower( preg_replace('[^a-zA-Z_:]', '',
$tag_name) );
fixed: $safe_tag = strtolower( preg_replace('/[^a-zA-Z_:]/', '',
$tag_name) );
file: wordpress-2.7\wp-includes\post-template.php
line: 610
current: $r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
fixed: $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
}}}
(Note: I hope I'm using the right bug posting protocol - please forgive me
if I'm not - its my first time posting anything over here in wp-land.
Also, I have not analyzed the code to evaluate the effects of any of these
typos.)
--
Ticket URL: <http://trac.wordpress.org/ticket/8986>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list