[BB Code: extra characters]

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
graphic
Registered User
Posts: 35
Joined: Mon Jun 09, 2003 2:25 am
Location: Chattanooga, TN
Contact:

[BB Code: extra characters]

Post by graphic »

Just curious, why does phpBB add extra characters in their bbcode when they store it in the database?

example

Code: Select all

[b:3k355]bold[/b:3k355]
What Is Real!? Coming 2005
Latest phpBB2 Styles: [What Is Real!?] [Avalanche]
User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: [BB Code: extra characters]

Post by Ptirhiik_ »

This is a key to identify it is a bbcode, and not something the user would have entered into brackets ([]).
User avatar
th23
Registered User
Posts: 112
Joined: Sat Jul 03, 2004 4:26 pm
Location: Bonn, Germany
Contact:

Re: [BB Code: extra characters]

Post by th23 »

And, if I understand correctly, it's there to know where exactly this tag starts and ends, so every tag has it's own hash to be sure that it's interpreted correctly if there is for example another b-tag within this one (for what reason ever).
graphic
Registered User
Posts: 35
Joined: Mon Jun 09, 2003 2:25 am
Location: Chattanooga, TN
Contact:

Re: [BB Code: extra characters]

Post by graphic »

I have thought about what you have suggested before I posted, but I can't see how adding an identifyer would help anything. If someone types in someing in brackets [p] then it won't get replaced with anything because it isn't a bbcode. If the user accedently types in [ b ] then it will get replaced weather they want it to or not.

There must be a reason, I just can't figure it out.
What Is Real!? Coming 2005
Latest phpBB2 Styles: [What Is Real!?] [Avalanche]
APTX
Registered User
Posts: 680
Joined: Thu Apr 24, 2003 12:07 pm

Re: [BB Code: extra characters]

Post by APTX »

This might have something todo with cacheing bbcode. I don't know what that does but it's used in functions with such a name.
Don't give me my freedom out of pity!
graphic
Registered User
Posts: 35
Joined: Mon Jun 09, 2003 2:25 am
Location: Chattanooga, TN
Contact:

Re: [BB Code: extra characters]

Post by graphic »

hmmm... maybe.
What Is Real!? Coming 2005
Latest phpBB2 Styles: [What Is Real!?] [Avalanche]
tm1000
Registered User
Posts: 23
Joined: Thu May 27, 2004 1:58 am

Re: [BB Code: extra characters]

Post by tm1000 »

this was written by psoTFX or someone else on the development team:
Here's v2.0 bbcode in a nutshell:

The problem is that parsing the nestable tags (code, quote, and list) is necessarily slow. There's no way around that, other than not actually bothering to find matching pairs of tags. But if we don;t find matching pairs of tags, users can thrash the layout of an entire page just by hanving an unmatched opening tag in their message.

So, what I did was break down that task into 2 separate steps:
1) Recognizing the tags.
2) Actually replacing the tags with HTML code.

Step 1 is done before we put the post in the database, and step 2 is done at pageview time.

What step 1 does is to replace a matching tag pair with a pair of the same tags, but with the addition of a UID string. Example:
.....
becomes [quote:UID] ..... [/quote:UID]. The UID part is currently a 10-character random alphanumeric string. Its length can be tweaked for performance, and I haven't decided what the final value will be yet.

So, the second pass can just blindly run a bunch of str_replace() calls, looking for "[quote:UID]" to replace with the starting quote HTML, and "[/quote:UID]" to replace with the ending quote HTML. This process is quite fast.

Also, the first pass can be very easily reversed for the editpost page - we just run str_replace() and basically strip the UIDs from the tags.

So, now the HTML that's used to generate BBCode is no longer stored in the database. This means that HTML can be changed, or specific tags disabled, at any time by the admin without breaking the reversal process, and with the effects taking place immediately across the whole board, including existing posts.
sparkster
Registered User
Posts: 182
Joined: Mon Jan 05, 2004 1:18 am

Re: [BB Code: extra characters]

Post by sparkster »

The BBCode UID is unique for each userand is stored in the users table.
tm1000
Registered User
Posts: 23
Joined: Thu May 27, 2004 1:58 am

Re: [BB Code: extra characters]

Post by tm1000 »

sparkster wrote:The BBCode UID is unique for each userand is stored in the users table.

thats not really true. the BBcode UID in the users table is for the users sig, if you look at the user's posts the UID is different for every post.
molotov
Registered User
Posts: 34
Joined: Mon Jul 26, 2004 6:30 pm

Re: [BB Code: extra characters]

Post by molotov »

tm1000 wrote:this was written by psoTFX or someone else on the development team:
This is an amazing description and really makes a lot of sense. I read this yesterday and I thought it was an amazing idea, then I was thinking about it again today and it really sunk in. As far as I know, other forums do not use anything like this, and i can see how this aproach is so much faster when displaying forums. As a programmer, congrats to whoever thought of this ;)
Post Reply