Fixed i broke the post parser

Jake Bunce

Well-known member
Paste this into a post and watch what happens:


[code]
[url="http://www.apple.com/]asdf[/url]
[/code]

[quote="Dean_test, post: 270791, member: 11467"]Life is grand :)[/quote]


Demo in next post...
 
For the purpose of experimentation... it works if you add an ending double quote to the URL tag, or if you make the QUOTE block unattributed.
 
I ran into the same issue trying to post something and for the first time in my life I kind of wanted to punch a baby. Was doing all sorts of whacky stuff (not just what you see in the example). lol

Solution ended up being to make sure I put nothing after the closing /CODE (obviously not a viable long-term solution... heh)
 
I ran into the same issue trying to post something and for the first time in my life I kind of wanted to punch a baby. Was doing all sorts of whacky stuff (not just what you see in the example). lol

Solution ended up being to make sure I put nothing after the closing /CODE (obviously not a viable long-term solution... heh)

Ah that explains what happened. I had some wacky stuff happening and wondering what the hell was going on.
 
I'm not sure this is fixable.

Our BB code parser automatically closes unclosed tags at the end of the post - this is a big element of what you're seeing. Obviously, the URL tag has been misformatted, but it actually finds a matching end with the quote tag. Because of that match, it has eaten the code close as part of the URL tag, so no code close tag is seen. Which means that it gets automatically closed at the end of the post.

Of course, given this is a code tag, the URL tag within shouldn't be parsed as BB code. Maybe that's an area I can target, but I'm not sure yet.
 
To put this into context... I originally discovered the problem with this code:

__________

[code]
$message['messageHtml'] = preg_replace('/\[url\]/', '', $post['message']);
$message['messageHtml'] = preg_replace('/\[url=".+"\]/', '', $post['message']);
$message['messageHtml'] = preg_replace('/\[\/url]/', '', $post['message']);
[/code]

[quote="who"]dddd[/quote]

__________

So this wasn't deliberate breakage. Afterwards I tried to narrow down the problem and was able to reproduce it with just a URL tag.
 
Actually, this was surprisingly easy to handle: if a "plain text" tag is opened, never let another tag try to be opened within it (as it can't be, it's always text).
 
Top Bottom