|
From: Nathan C. <na...@us...> - 2001-12-11 08:43:08
|
Update of /cvsroot/phpbb/phpBB2/includes
In directory usw-pr-cvs1:/tmp/cvs-serv4052/includes
Modified Files:
functions.php
Log Message:
bug #488067: no, preg_quote() didn't always have 2 args.
Index: functions.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/includes/functions.php,v
retrieving revision 1.91
retrieving revision 1.92
diff -C2 -r1.91 -r1.92
*** functions.php 2001/12/11 02:21:51 1.91
--- functions.php 2001/12/11 08:43:05 1.92
***************
*** 840,844 ****
for($i = 0; $i < count($smilies); $i++)
{
! $orig[] = "/(?<=.\\W|\\W.|^\\W)" . 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">';
}
--- 840,844 ----
for($i = 0; $i < count($smilies); $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">';
}
***************
*** 888,892 ****
for($i = 0; $i < count($word_list); $i++)
{
! $word = str_replace("\*", "\w*?", preg_quote($word_list[$i]['word'], "#"));
$orig_word[] = "#\b(" . $word . ")\b#i";
--- 888,892 ----
for($i = 0; $i < count($word_list); $i++)
{
! $word = str_replace("\*", "\w*?", phpbb_preg_quote($word_list[$i]['word'], "#"));
$orig_word[] = "#\b(" . $word . ")\b#i";
***************
*** 1177,1180 ****
--- 1177,1200 ----
}
+
+
+
+ //
+ // 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;
+ }
+
?>
|