mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-31 11:39:37 +02:00
bug #488067: no, preg_quote() didn't always have 2 args.
git-svn-id: file:///svn/phpbb/trunk@1553 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
46deea9011
commit
f0bf32c5c1
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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>";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user