• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed i broke the post parser

Jake Bunce

XenForo moderator
Staff member
#1
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...
 

Jake Bunce

XenForo moderator
Staff member
#2
Code:
[url="http://www.apple.com/]asdf[/url]
[/code]

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

Jake Bunce

XenForo moderator
Staff member
#3
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.
 

digitalpoint

Well-known member
#5
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)
 

Shelley

Well-known member
#6
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.
 

Mike

XenForo developer
Staff member
#7
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.
 

Jake Bunce

XenForo moderator
Staff member
#8
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.
 

Mike

XenForo developer
Staff member
#9
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).