I'm using phpBugtracker and I'm pretty new to php, but I would like to know how to allow backslashes in the comments. I noticed that only backslashes get striped but forward slashes stay. (I did manage to get 1 backslash to show when I put in 5)
Any help is appreciated!
$patterns = array(
'//',
'/</',
'/>/',
'/
/',
'/(bug)[[:space:]]?(#?)([0-9]+)/i', // matches bug #nn
'/cvs:([^\.\s:,\?!]+(\.[^\.\s:#,\?!]+)*)([:#](rev|r)?)?(\d\.[\d\.]+)?([\W\s])?/i', // matches cvs:filename.php, cvs:filename.php:n.nn or cvs:filename.php#revn.nn
'/<pre>/', // preformatted text
'/<\/pre>/', // preformatted text
);
$replacements = array(
'',
'<',
'>',
'<br>',
"<a href='$me?op=show&bugid=\\3'>\\1 #\\3</a>", // internal link to bug
'<a href="'.CVS_WEB.'\\1#rev\\5" target="_blank">\\1</a>\\6', // external link to cvs web interface
'<pre>',
'</pre>',
);
return preg_replace($patterns, $replacements, stripslashes($comments));
The reason the slashes are being stripped is because you are passing $comments
through stripslashes
. Just pass it in as-is and it should be ok. Worth doing some thorough testing to make sure that won't open up a security hole.