2007-03-24, 01:24 AM
This is from a previous thread:
http://community.mybboard.net/showthread.php?tid=17588
Tikitiki asked me to post here, so:
http://community.mybboard.net/showthread.php?tid=17588
Tikitiki asked me to post here, so:
Quote:Tikitiki Wrote:As for {{mybb-code}} I ask you to not use it, as there is no other alternative.Nah, I don't mind that, but I'm suggesting the { and } characters, entered by the user gets replaced with the &xxxx; equivalents. This is what I use in the parser:
Oh, and replacing the \ character at that point fixes another bug with the parser.// If MyCode needs to be replaced, first filter out [code] and [php] tags. if($options['allow_mycode'] != "no") { //replace \, { and }s to save trouble later $message = str_replace("{", '{', $message); $message = str_replace("}", '}', $message); $message = str_replace("\\", '\', $message); $message = str_replace("\"", '"', $message); // First we split up the contents of code and php tags to ensure they're not parsed. preg_match_all("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", $message, $code_matches, PREG_SET_ORDER); $message = preg_replace("#\[(code|php)\](.*?)\[/\\1\](\r\n?|\n?)#si", "{{mybb-code}}\n", $message); }
*EDIT* Note that the '\' is really '\' - this is also a bug :|