MyBB Community Forums
[F] Bugs in parser - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.2.7 (https://community.mybb.com/forum-55.html)
+------ Thread: [F] Bugs in parser (/thread-17622.html)



[F] Bugs in parser - Yumi - 03-24-2007

This is from a previous thread:
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:
		// 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);
		}
Oh, and replacing the \ character at that point fixes another bug with the parser.
*EDIT* Note that the '\' is really '\' - this is also a bug :|



RE: Bugs in parser - Ryan Gordon - 04-05-2007

Wouldn't replacing { and } mess up the PHP parser? Since it depends on valid code to highlight it wouldn't recognize &#x7B/D as a valid { / } character.


RE: Bugs in parser - Martin M. - 05-13-2007

We could change it to { before the PHP code parser is initialized then we could change it back within the php code tag function - since it only matches the text within the PHP code tag.
But might be overkill though.


RE: Bugs in parser - Ryan Gordon - 05-13-2007

I agree, I'd just say don't use it please Toungue


RE: Bugs in parser - Martin M. - 05-19-2007

ZiNga BuRgA Wrote:This is from a previous thread:
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:
		// 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);
		}
Oh, and replacing the \ character at that point fixes another bug with the parser.
*EDIT* Note that the '\' is really '\' - this is also a bug :|

but but \ already gets converted to \. . .
And also the bug with \ should be \ seems to only exist after editing?
Also other parts of your code will break the whole idea with an highlighter. We can't convert " to &quote; before after the php highlight function has been ran.


RE: Bugs in parser - Chris Boulton - 06-17-2007

I've made a change to this.

The tags are now converted to <mybb-code>. Why? You cannot use HTML in posts and by that time any input of HTML has been converted to &gt; and &lt;.

It's a bit of a "hack" but it solves this problem short of converting different characters such as { and } to entity equivalents which will break the [php] tag parser.


RE: [F] Bugs in parser - Chris Boulton - 06-17-2007

This bug has been fixed in the latest code.

Please note the latest code is not live on the site or for download. An update will be released which contains this fix.