MyBB Community Forums

Full Version: preg_replace with (x|) annihilates message if quote is not closed and too long
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We should add #u to all preg_match where it works with message.

If there is no #u, it can behave strangely with non latin characters

Specificlly here:
inc\class_parser.php
mycode_parse_quotes()
		$pattern = array(
			"#\[quote=([\"']|"|)(.*?)(?:\\1)(.*?)(?:[\"']|")?\](.*?)\[/quote\](\r\n?|\n?)#esi",
			"#\[quote\](.*?)\[\/quote\](\r\n?|\n?)#si"
		);
I had issue with some text without closed quote, adding #u solved problem. Text just disappeared. The strange thing is that text should be very specific, changing just a little make him appear again.
Could you please provide any example? I haven't noticed any problems with unicode characters yet.
I was wrong, it has nothing to do with unicode. I renamed thread.

The problem is here:
$pattern_callback = "#\[quote=([\"']|"|)(.*?)(?:\\1)(.*?)(?:[\"']|")?\](.*?)\[/quote\](\r\n?|\n?)#si";
here -> (....|)
Does it search for nothing?? And than callbacking it \1?? Quote is not closed, so it searching through all text to the end.

It seams that some servers can't handle it. Only if text size is small. Maybe some Apache or php parameter.
When I delete it "([\"']|"|)" -> "([\"']|" )" everything is working again.

I suggest to change this regexp, 1.6 too


This text shows nothing in my localhost, but it is working here:
[quote='xxxx' pid='1111' dateline='22222']
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

If i delete one row, it is working again. If i delete "(..|)", it is working too.
If I close quote it also works. But some users mess it and don't close quote.
An issue with quotes erasing messages has been fixed a while ago: http://dev.mybb.com/issues/956
Are you sure you are using the latest MyBB version and inc/class_parser.php is up-to-date?
Okay, thanks, I see it.
My version is 1.6.10, I wanted to update after 1.8 stabilized.


Then it seems better to move this topic from here. My bad.

Quote:Andreas Klauer almost 3 years ago
The pattern used to match the quote tag is too complex and hits the backtracking limit if the post structure is complicated, or worse, incorrect (such as missing quote tag). As a result the preg_replace() errors out and does the worst thing possible in that it returns NULL. Which kills the entire message and makes the post appear as empty. Which sucks because it does not give the user any indication as to what is wrong with his post.
Well, yes, you always should be up-to-date. Moved to General Support.
(2014-06-18, 04:06 PM)Destroy666 Wrote: [ -> ]Well, yes, you always should be up-to-date.
That is true. But my forum have some inner tweaks and almost every update I should spend time to restore them. So I try to update only every 3-5 updates. Now I am waiting for 1.8 to make it all at once.