diff options
author | natec <natec@users.sourceforge.net> | 2001-12-11 08:43:05 +0000 |
---|---|---|
committer | natec <natec@users.sourceforge.net> | 2001-12-11 08:43:05 +0000 |
commit | f0bf32c5c1d7bcacab86e0623b0600c2a694303c (patch) | |
tree | cdbc1ec6a224831de763f45df775439e8f5897cf /phpBB | |
parent | 46deea9011ccb78637bbcd355f4cba352b0980fd (diff) | |
download | forums-f0bf32c5c1d7bcacab86e0623b0600c2a694303c.tar forums-f0bf32c5c1d7bcacab86e0623b0600c2a694303c.tar.gz forums-f0bf32c5c1d7bcacab86e0623b0600c2a694303c.tar.bz2 forums-f0bf32c5c1d7bcacab86e0623b0600c2a694303c.tar.xz forums-f0bf32c5c1d7bcacab86e0623b0600c2a694303c.zip |
bug #488067: no, preg_quote() didn't always have 2 args.
git-svn-id: file:///svn/phpbb/trunk@1553 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/develop/search_fill.php | 7 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 24 | ||||
-rw-r--r-- | phpBB/posting.php | 4 | ||||
-rw-r--r-- | phpBB/search.php | 8 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 2 |
5 files changed, 33 insertions, 12 deletions
diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php index 2c34a3a314..4a38fcde19 100644 --- a/phpBB/develop/search_fill.php +++ b/phpBB/develop/search_fill.php @@ -146,6 +146,7 @@ include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'config.'.$phpEx); include($phpbb_root_path . 'includes/constants.'.$phpEx); include($phpbb_root_path . 'includes/db.'.$phpEx); +include($phpbb_root_path . 'includes/functions.'.$phpEx); print "<html>\n<body>\n"; @@ -162,14 +163,14 @@ $synonym_array = file($phpbb_root_path . "language/lang_english/search_synonyms. for ($j = 0; $j < count($stopword_array); $j++) { $filter_word = trim(strtolower($stopword_array[$j])); - $search[] = "/\b" . preg_quote($filter_word, "/") . "\b/is"; + $search[] = "/\b" . phpbb_preg_quote($filter_word, "/") . "\b/is"; $replace[] = ''; } for ($j = 0; $j < count($synonym_list); $j++) { list($replace_synonym, $match_synonym) = split(" ", trim(strtolower($synonym_list[$j]))); - $search[] = "/\b" . preg_quote(trim($match_synonym), "/") . "\b/is"; + $search[] = "/\b" . phpbb_preg_quote(trim($match_synonym), "/") . "\b/is"; $replace[] = " " . trim($replace_synonym) . " "; } @@ -313,7 +314,7 @@ for(;$postcounter <= $max_post_id; $postcounter += $batchsize) } /* - //$phrase_string = preg_replace("/\b" . preg_quote($word[$j], "/") . "\b/is", $word_id, $phrase_string); + //$phrase_string = preg_replace("/\b" . phpbb_preg_quote($word[$j], "/") . "\b/is", $word_id, $phrase_string); $phrase_string = trim(preg_replace("/ {2,}/s", " ", str_replace(array("*", "'"), " ", $phrase_string))); $sql = "INSERT INTO phpbb_search_phrasematch (post_id, phrase_list) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 01ef706e13..204e180dc8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -839,7 +839,7 @@ function smilies_pass($message) usort($smilies, 'smiley_sort'); for($i = 0; $i < count($smilies); $i++) { - $orig[] = "/(?<=.\\W|\\W.|^\\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W$)/i"; + $orig[] = "/(?<=.\\W|\\W.|^\\W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.\\W|\\W.|\\W$)/i"; $repl[] = '<img src="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0">'; } @@ -887,7 +887,7 @@ function obtain_word_list(&$orig_word, &$replacement_word) for($i = 0; $i < count($word_list); $i++) { - $word = str_replace("\*", "\w*?", preg_quote($word_list[$i]['word'], "#")); + $word = str_replace("\*", "\w*?", phpbb_preg_quote($word_list[$i]['word'], "#")); $orig_word[] = "#\b(" . $word . ")\b#i"; $replacement_word[] = $word_list[$i]['replacement']; @@ -1177,4 +1177,24 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", } + + +// +// this does exactly what preg_quote() does in PHP 4-ish: http://www.php.net/manual/en/function.preg-quote.php +// +// This function is here because the 2nd paramter to preg_quote was added in some +// version of php 4.0.x.. So we use this in order to maintain compatibility with +// earlier versions of PHP. +// +// If you just need the 1-parameter preg_quote call, then don't bother using this. +// +function phpbb_preg_quote($str, $delimiter) +{ + $text = preg_quote($str); + $text = str_replace($delimiter, "\\" . $delimiter, $text); + + return $text; +} + + ?> diff --git a/phpBB/posting.php b/phpBB/posting.php index 32fc055f4e..200971dd00 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -70,7 +70,7 @@ function clean_words($entry, &$stopword_list, &$synonym_list) for ($j = 0; $j < count($stopword_list); $j++) { $filter_word = trim(strtolower($stopword_list[$j])); - $entry = preg_replace("/\b" . preg_quote($filter_word, "/") . "\b/is", " ", $entry); + $entry = preg_replace("/\b" . phpbb_preg_quote($filter_word, "/") . "\b/is", " ", $entry); } } @@ -79,7 +79,7 @@ function clean_words($entry, &$stopword_list, &$synonym_list) for ($j = 0; $j < count($synonym_list); $j++) { list($replace_synonym, $match_synonym) = split(" ", trim(strtolower($synonym_list[$j]))); - $entry = preg_replace("/\b" . preg_quote(trim($match_synonym), "/") . "\b/is", " " . trim($replace_synonym) . " ", $entry); + $entry = preg_replace("/\b" . phpbb_preg_quote(trim($match_synonym), "/") . "\b/is", " " . trim($replace_synonym) . " ", $entry); } } diff --git a/phpBB/search.php b/phpBB/search.php index 7b3634fe38..788d930765 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -64,7 +64,7 @@ function remove_stop_words($entry, &$stopword_list) $filter_word = trim(strtolower($stopword_list[$j])); if( $filter_word != "and" && $filter_word != "or" && $filter_word != "not" ) { - $entry = preg_replace("/\b" . preg_quote($filter_word, "/") . "\b/is", " ", $entry); + $entry = preg_replace("/\b" . phpbb_preg_quote($filter_word, "/") . "\b/is", " ", $entry); } } } @@ -83,7 +83,7 @@ function replace_synonyms($entry, &$synonym_list) if( $match_synonym != "and" && $match_synonym != "or" && $match_synonym != "not" && $replace_synonym != "and" && $replace_synonym != "or" && $replace_synonym != "not" ) { - $entry = preg_replace("/\b" . preg_quote(trim($match_synonym), "/") . "\b/is", " " . trim($replace_synonym) . " ", $entry); + $entry = preg_replace("/\b" . phpbb_preg_quote(trim($match_synonym), "/") . "\b/is", " " . trim($replace_synonym) . " ", $entry); } } } @@ -848,7 +848,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) { $highlight_active .= " " . $split_word; - $search_string[] = "#\b(" . str_replace("\*", ".*?", preg_quote($split_word, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i"; + $search_string[] = "#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($split_word, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i"; $replace_string[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>"; for ($k = 0; $k < count($synonym_array); $k++) @@ -857,7 +857,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) if( $replace_synonym == $split_word ) { - $search_string[] = "#\b(" . str_replace("\*", ".*?", preg_quote($replace_synonym, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i"; + $search_string[] = "#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($replace_synonym, "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i"; $replace_string[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>"; $highlight_active .= " " . $match_synonym; diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index f132455c0d..9116812e3c 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -548,7 +548,7 @@ if( isset($HTTP_GET_VARS['highlight']) ) { if( trim($words[$i]) != "" ) { - $highlight_match[] = "#\b(" . str_replace("\*", ".*?", preg_quote($words[$i], "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i"; + $highlight_match[] = "#\b(" . str_replace("\*", ".*?", phpbb_preg_quote($words[$i], "#")) . ")(?!.*?<\/a>)(?!.*?\[/url\])\b#i"; $highlight_replace[] = "<font color=\"#" . $theme['fontcolor3'] . "\"><b>\\1</b></font>"; } } |