1

Topic: <br /> vs. <p> and a few other questions...

Okay.....

So why are \n in posts replaced with <br /> rather than </p><p>. I've just modified my PunBB to use <p> and it's working well. Am I missing something?

Second of all, why aren't messages parsed, before they are stored in the database. It seems like it would be a LOT lighter on the server. The only potential drawback I can see would be if parsing options are changed after an article was posted, which doesn't really seem like a big problem to me.

So what's up Rickard? Let me in on the mind of a genius... big_smile

2

Re: <br /> vs. <p> and a few other questions...

1. Thats already dealt with in the next vesion.

2. If  you parse messages before you store them how would you deal with existing messages either in a database that has been converted to PunBB or when there are upgrades to PunBB or even just parser.php.

3

Re: <br /> vs. <p> and a few other questions...

Paul, presumably "parsed" messages are just plain old HTML, which every database supports. Sure there COULD be instances in which another board could produce code that breaks something in PunBB, but since most posts are a <p> element (or a series of them) with <br /> and <img /> tags and a few other formatting tags, I can't really see how this could hurt. Worst case scenario, you would get unparsed text from another database, in which the migration tools that everyone seems to love so much would just have to include the PunBB parser in the migration process. Very doable, I'd say.

Re: <br /> vs. <p> and a few other questions...

Well, parsing before inserting the message into the DB would be bad, as you would lose your edit function tongue If you'd allow people to edit the HTML, you can see plently of security risks tongue

5

Re: <br /> vs. <p> and a few other questions...

Elbekko, why not de-parse when letting users edit? Surely edits are a LOT less common than views, so you'd still be executing much less code.

Re: <br /> vs. <p> and a few other questions...

One reason would be the amount of space in the DB
Look at the image tag for a smiley. Now, try storing that in the subject of a topic and keeping all the already existing info.

7 (edited by ethos 2006-06-16 21:58)

Re: <br /> vs. <p> and a few other questions...

Smartys, finally an acceptable answer.

But why not make it toggleable? Doesn't seem like it would be too hard to do that. One setting for people without a lot of space to store the data that would post-parse, one setting for people that want faster performance that would pre-parse.

Not to mention the fact that if you have smileys disabled, there's really no argument there at all. :-)

8 (edited by Smartys 2006-06-17 00:12)

Re: <br /> vs. <p> and a few other questions...

It's not a matter of something you can toggle or just space, it's a matter of the datatype used.
With smilies: subject is a varchar(255). One smiley looks like this

<img src="img/smilies/big_smile.png" width="15" height="15" alt="big_smile" />

or like this

:D

Guess which one you want to go with so that the user doesn't have their subject cut off?

With quotes, for example:

<blockquote><div class="incqbox"><h4>Person wrote:</h4><p>stuff</p></div></blockquote>

Versus

[quote=Person]stuff[/quote]

Especially when people make longer posts, they would find it annoying when "what they see" in terms of post length isn't what they get (they'll get an error saying their post is too long).

Plus there's the fact that you can implement an alternative parser to change how these things work without too much trouble.

There's also the issue with search where posts aren't parsed because only the first 1000 characters are shown and the BBCode could suddenly end in the middle. Much bigger issue with HTML

And finally, I believe Rickard uses pun_htmlspecialchars on these posts before displaying them. If he would implement your idea, he would have to run that beforehand as well (otherwise you'll have the HTML just displaying as normal text) which means that anyone who can manage to insert or update a post can create an XSS issue.

9

Re: <br /> vs. <p> and a few other questions...

Good job.

I'm not a jerk. I just like to debate things until I'm sure the idea wouldn't be worth entertaining. You just convinced me, which isn't usually easy.

So good job.

Re: <br /> vs. <p> and a few other questions...

Don't worry, I debate a similar way tongue

Re: <br /> vs. <p> and a few other questions...

The main reason is convenience. It's easier to just transform the post when displaying it. It also leaves the door open for any potential changes to the parsing routines and it makes life a lot easier for mod/extension authors who want to alter the way the parser works.

"Programming is like sex: one mistake and you have to support it for the rest of your life."