diff --git a/lib/function.php b/lib/function.php
index c027fbb..4ce857c 100644
--- a/lib/function.php
+++ b/lib/function.php
@@ -466,6 +466,15 @@ function doreplace($msg, $posts, $days, $username, &$tags = null) {
return $msg;
}
+
+function escape_codeblock($text) {
+ $list = array("[code]", "[/code]", "<", "\\\"" , "\\\\" , "\\'", "[", ":", ")", "_");
+ $list2 = array("", "", "<", "\"", "\\", "\'", "[", ":", ")", "_");
+
+ // @TODO why not just use htmlspecialchars() or htmlentities()
+ return "[quote]". str_replace($list, $list2, $text[0]) ."
[/quote]";
+}
+
function doreplace2($msg, $options='0|0'){
// options will contain smiliesoff|htmloff
$options = explode("|", $options);
@@ -475,8 +484,7 @@ function doreplace2($msg, $options='0|0'){
$list = array("<", "\\\"" , "\\\\" , "\\'", "[", ":", ")", "_");
$list2 = array("<", "\"", "\\", "\'", "[", ":", ")", "_");
- $msg=preg_replace("'\[code\](.*?)\[/code\]'sie",
- '\''."[quote]".'\''.'.str_replace($list,$list2,\'\\1\').\'
[/quote]\'',$msg);
+ $msg=preg_replace_callback("'\[code\](.*?)\[/code\]'si", 'escape_codeblock',$msg);
if ($htmloff) {
@@ -514,8 +522,6 @@ function doreplace2($msg, $options='0|0'){
$msg=preg_replace("'\[img\](.*?)\[/img\]'si", '
', $msg);
$msg=preg_replace("'\[url\](.*?)\[/url\]'si", '\\1', $msg);
$msg=preg_replace("'\[url=(.*?)\](.*?)\[/url\]'si", '\\2', $msg);
- $msg=preg_replace("/\[trope\](.*?)\[\/trope\]/sie", "''.formatting_trope('\\1').''", $msg);
- $msg=preg_replace("/\[trope=(.*?)\](.*?)\[\/trope\]/sie", "'\\2'", $msg);
$msg=str_replace('http://nightkev.110mb.com/justus_layout.css','about:blank',$msg);
do {