Jump to content

bbcode parser problem


Monkuar

Recommended Posts

Everything works fine, unless I add this stupid thing to get rid of people using HTML

$text = pun_htmlspecialchars($text);

 

Once I add that to my function, no bbcodes work at all?  But I cant use html.. (which is good) but I need to beable to use BBCODE, and parse hackers from using html also, any help?

 

 

 

MY CODE absolutely destroyed the forum page

 

here it is:

 

http://pastebin.com/jv7m47kn

Link to comment
Share on other sites

what does pun_htmlspecialchars do?

 

The proper thing to do is:

1)  call htmlspecialchars on the string

 

2)  parse the BBcode to turn BBcode into HTML

 

3)  display

 

does

 

function pun_htmlspecialchars($str)
{
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}

 

This is my code:

 

http://pastebin.com/m0gmXAfQ

 

see my

$text = pun_htmlspecialchars($text);

right under global?

 

i am calling it before?

Link to comment
Share on other sites

There's a lot of functionality missing here that we'd need to see.  This is so huge and poorly organized that you're going to have to debug this yourself, step by step.  Do you know where the disconnect is?  Does clean_paragraphs do anything special?  Why do you only replace 7 smilies? 

Link to comment
Share on other sites

There's a lot of functionality missing here that we'd need to see.  This is so huge and poorly organized that you're going to have to debug this yourself, step by step.  Do you know where the disconnect is?  Does clean_paragraphs do anything special?  Why do you only replace 7 smilies?

 

Well because I dont want people to spam smiley images on my message board and eat up bandwidth so I only make it so people can use 7 of each smiley,

 

all I do is wrap

 

$db->escape(parse_message($message))

 

before it enters into my database, should I use the html entities thing before that? then use parse?

Link to comment
Share on other sites

This won't do 7 of each, it will do 7 total.  Even if you did do 7 of each, browsers are smart enough not to download 8,000 copies of the same image, they'll use the one they downloaded for every <img> tag.

 

You keep describing your code using functions that none of us can see.  We had to ask about your custom htmlentities function, which apparently did nothing other than the built-in one, but you've now introduced escape(), parse_message(), and clean_paragraphs()

 

Again, debug this yourself.  Dump the input to a log file every step of the way, figure out when [ b ] turns into <b> and/or when it turns into <b>

 

And Scoot is right, parsing BBcode is a display event, not a storage event.

Link to comment
Share on other sites

Well everything seems to work now maniac. Here is everthing.

 

I use the

 

$message = parse_message($message, $errors); 

 

Then when it enters into my database: I use

 

$db->escape($message)

 

$db escape is just a mysql escape string return function.

 

 

Then when I view the message, I dont use any parser to read it, I let html read it, because it's already been converted into html.

 

It's not letting me submit <b>hey</b> or html tags though! so that's good! :) (no hackers)

 

Here is the full parser:

 

http://pastebin.com/DSKzHGLm

 

the prob was I was calling the parser on $message before it entered the database twice, which was making it do weird thing.

 

 

What I just explained above, is working now, html is not working and bbcode's are.

 

I have unconvert functions though so people can edit, but will work on that later

 

 

 

 

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.