Board logo

Code tags and eating backslashes
MikeRJ - 28/11/07 at 11:12 PM

Would it be possible for an admin to fix the code tags? Currently it double spaces everything which is not very handy for ASCII diagrams etc.

Also, why does the forum eat backslashes even within code sections?


Fozzie - 28/11/07 at 11:24 PM

Mike, only ChrisW does stuff with codes etc....

I can't say as I have noticed anything untoward from this end, but I will point Chris in the direction of your post next time we speak!

Fozzie


MikeRJ - 28/11/07 at 11:31 PM

Cheers Fozzie

As a quick test, start a post and put say ten back slashes in it, then click Preview Post. In the preview it will show only two backslashes, and in the original post there will only be 5 backslashes left. Each time you click preview (or post) it eats more of them


Fozzie - 28/11/07 at 11:35 PM

You are right!

It ate 3 of them in one go!

It ate \\ (should be 8) ......

Fozzie


02GF74 - 29/11/07 at 08:01 AM

I'd rather eat my colon than your backslashes


martyn_16v - 29/11/07 at 09:50 AM

Backslashes are used as escape characters to help store special characters in a database (e.g n is a newline, t is a tab). All posts that get entered will have all of their special characters converted like this before they get stored on the forum database to try and stop people entering potentially harmful code within posts. When the post is then read back out of the database these special characters are then restored so the message should read properly, but unfortunately backslashes often get left behind


Fozzie - 29/11/07 at 12:25 PM

Thanks for that martyn!

As said, I don't 'do' codes..... so all gobbledegook to me

Doesn't sound too crucial to me, in 'normal' use of the site........

Fozzie


MikeRJ - 29/11/07 at 12:59 PM

quote:
Originally posted by martyn_16v
When the post is then read back out of the database these special characters are then restored so the message should read properly, but unfortunately backslashes often get left behind


I assumed it was an escape character problem, but the escape code for a backslash is two backslashes, so putting double the amount in *should* work. This all goes to pot if you do a preview though.

I also thought that anything in a [ code ] section was stored with no formatting conversion? I've certainly not encountered this particular issue on other forums.


martyn_16v - 29/11/07 at 04:32 PM

Everything should be 'made safe', even if it's in a code tag, otherwise it may be possible for an attacker to enter SQL commands within a post. How it's implemented varies from forum to forum (and between programming languages). PHP has some built in functions to do this, they have their foibles but they work reasonably well, so the majority of forums that run on phpbb/vbulletin probably work fine. I do remember having to fiddle with a web wiz forum once (written in ASP) that did a similar thing to this, but it was so long ago I can't remember specifics.