Jump to content

Escaping BBtags


russy

Recommended Posts

I'm making a script that uses BBtags. I'll do my best to explain my problem.

 

Lets say we have a user named: bob[hi]yay\

 

If you have that username, in a lot of forums it tends to cause a problem, such as:

yay\]test

 

Basically I want to have it so you can escape the [ ] and \ characters, and regular expression will pick up on whats escaped and whats not. I have a basic understanding of regular expressions, and heres my older code that ignores escaping characters:

 

$parse['data'] = preg_replace("{\[{$bbtag['tag']}=(.+?)\](.+?)\[/{$bbtag['tag']}\]}sei", "\$this->bbtag({$bbtag['id']}, '\\2', '\\1')", $parse['data']);

 

The thing is it has to ignore a \], however NOT ignore a \\] which is the problem for me. Any help would be great, thank you.

Link to comment
Share on other sites

- Why are brackets valid in the first place?

- Are you saying that "bob[hi]yay\" is going to be inserted into the database as "bob\[hi\]yay\", thus allowing you to ignore the brackets?

- Depending on the number of tags you have, you can disallow invalid tags.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.