Jump to content


Photo

More than 51 urls will not parse properly in BBCode


More than 51 urls will not parse properly in BBCode. I made a test post on these forums and saw a similar issue.

http://forums.invisi...-51-urls-parse/

Status: Cannot Reproduce
Version: 3.3.4
Fixed In: 0


30 Comments

Updating status to: Confirmed - General
Updating severity to: 3 - Medium

I added infinite loop protection, but obviously 50 isn't going to be sufficient.

Need to come up with a number that will be sufficient, while still having the same effect (stop it from having the possibility of looping forever).
I have a feeling that this may also extend to other BBCodes, as I've noticed that posts in my board that use a lot of codes have suddenly had a lot of them stop parsing since 3.0.3. In fact, counting a few, it seems to be once there's been around 51 non-quote codes in the post.

As an example.


Maybe this protection could be re-engineered into a BBCode limit option in the ACP, like how there's an emoticon limit.

added infinite loop protection, but obviously 50 isn't going to be sufficient.


Maybe set the limit based on the length of the post. A post can't have more than ("length in bytes" / 10) bbcodes, for example. This prevents inifinite loops, but will never not process a code.
Is there a quick way to fix this in the meantime?
I haven't installed 3.0.3 yet so I cannot test this, but open up admin/sources/classes/bbcode/core.php. Find:

//-----------------------------------------
		// Protect against endless loops
		//-----------------------------------------
		
		static $iteration	= array();
		
		if( array_key_exists( $tag, $iteration ) AND $iteration[ $tag ] > 50 )
		{
			return $txt;
		}
If you change '50' to another, larger number, that should help. I make no guarantees that it does, though, since I haven't tested this on my system. Yet.

..Al
Whats it set to in 3.0.2?

Whats it set to in 3.0.2?

It's not in 3.0.2.

..Al

I added infinite loop protection, but obviously 50 isn't going to be sufficient.

Need to come up with a number that will be sufficient

I am using BBCodes and emoticons to post Amazon and iTunes affiliate links for music playlists that can have as many as 100 tracks. I can easily reach 500 BBCodes/URLs and 400 emoticons in a single post.

I haven't installed 3.0.3 yet so I cannot test this, but open up admin/sources/classes/bbcode/core.php. Find:

//-----------------------------------------
 // Protect against endless loops
 //-----------------------------------------
 
 static $iteration = array();
 
 if( array_key_exists( $tag, $iteration ) AND $iteration[ $tag ] > 50 )
 {
 return $txt;
 }
If you change '50' to another, larger number, that should help. I make no guarantees that it does, though, since I haven't tested this on my system. Yet.

..Al


Thanks, but the number there is already set to 500 (I haven't changed it yet)...

UPDATE: I Changed it to 5000 and it seems to have fixed the issue, at least temporarily. Thanks for the suggestion and help, very much appreciated.

Thanks, but the number there is already set to 500 (I haven't changed it yet)...

UPDATE: I Changed it to 5000 and it seems to have fixed the issue, at least temporarily. Thanks for the suggestion and help, very much appreciated.

500! Huh, I only downloaded the file a few hours ago and it was set to 50. Interesting...

Glad adjusting it worked on your board. I'll be setting it pretty high myself as well (I'm glad I saw this before I upgraded my board to 3.0.3, which I'm working on right now)..

..Al

500! Huh, I only downloaded the file a few hours ago and it was set to 50. Interesting...

Glad adjusting it worked on your board. I'll be setting it pretty high myself as well (I'm glad I saw this before I upgraded my board to 3.0.3, which I'm working on right now)..

..Al


Al, you were right, and what happened was IPS support changed it to 500 right before I changed it to 5,000. Thanks again for the help, much appreciated.

Al, you were right, and what happened was IPS support changed it to 500 right before I changed it to 5,000. Thanks again for the help, much appreciated.

Ahh, good--I was starting to wonder if Invision had modified the download package at some point. :D

..Al
There's alot more places it needs to be changed.

Find all references to 50 in the admin/sources/classes/bbcode/core.php file and raise that.. Should be 2..

Then same thing in /admin/sources/classes/bbcode/custom/defaults.php and there's about 6 of them in there.

There's alot more places it needs to be changed.

Find all references to 50 in the admin/sources/classes/bbcode/core.php file and raise that.. Should be 2..

Then same thing in /admin/sources/classes/bbcode/custom/defaults.php and there's about 6 of them in there.

Thanks, I changed them all. I should have spent more time looking, especially since there are only a few files there.

That really should be a single constant somewhere.. :whistle:

..Al
This was new protection to prevent infinite looping (have only seen it occur in 3.0.2+ with converted boards that have really bad bbcodes saved), but yes, 50 is obviously not going to work. Nothing popped up in local tests, which is why I didn't see an issue originally.

For the record, that limit is per-bbcode, not global. So you could use 50 bold tags, 50 url tags, etc. but no more. We'll change it higher to prevent the problem in the next release.
Thanks for the tip, guys.
It solved my problem :)
Editing this didn't help:
//-----------------------------------------
 // Protect against endless loops
 //-----------------------------------------
 
 static $iteration = array();
 
 if( array_key_exists( $tag, $iteration ) AND $iteration[ $tag ] > 50 )
 {
 return $txt;
 }

but editing this one, did:

// Stop infinite loops
						//-----------------------------------------
						
						if( $_iteration > [b]5000[/b] )
						{
							break;
						}
I did both changes but they still aren't processing for me. Not sure exactly why.

Also the code

// Stop infinite loops
                                                //-----------------------------------------
                                                
                                                if( $_iteration > [b]5000[/b] )
                                                {
                                                        break;
                                                }

appears as

// Stop infinite loops
                                                //-----------------------------------------
                                                
                                                if( $_iteration > 50 )
                                                {
                                                        break;
                                                }

on mine

But yes, no love for me. Could it be something else? I changed the first file and the other 4 on the other file to 5000 (from the default 50)
What do you mean by "appears as"?
Did you change 50 to 5000 and did you SAVE the file after making changes?
hi broni,

Yes they are saved. I use vi in shell to edit so I know its saved ;)

As for what I mean on the "/admin/sources/classes/bbcode/custom/defaults.php" file

it was previously

 //-----------------------------------------
                                // Stop infinite loops
                                //-----------------------------------------

                                if( $_iteration > 50 )
                                {
                                        break;
                                }


now they all have been changed with 5000

 //-----------------------------------------
                                // Stop infinite loops
                                //-----------------------------------------

                                if( $_iteration > 5000 )
                                {
                                        break;
                                }





FYI I have IPB 3.0.3
Try to clear browser cache (Tools>Clear recent history).
Restart browser.
Hi borni,

I have tried doing that (clear cache and reload) on IE, FF and safari and still no love.
I'm not sure then. You may want to open a ticket. Let them know, what you tried.
Updating status to: Fixed
Issue fixed in: 3.0.4

Fixed for all BBcodes.
I got a response from the ticket system which resolved the problem.

Basically you have to delete the Cache Post which is under System Settings --> Tools and Settings --> Cache Management --> Cached Posts

The board was just caching the problem. ;)
Photo
Rainbow Dash
Oct 19 2009 02:14 AM
That's just funny. 500 is a solution? The better way is to create additional settings field named "Max BBCodes count" in server performance settings group, or, at last, put constant in conf_global.php. There is no way with rawcoded 500 digit. I'm changing it manually to 5000 every time after upgrade :(