Page 1 of 1
slashes and html in messages
Posted: Thu Jan 11, 2007 6:48 pm
by Sub_Zero
Hey
You have a bug in your message system.....
The recieved message shows slashes and screwed up html codes....
The solution is to add this to the code:
Code: Select all
$message = htmlentities(stripslashes($message));
That's all...
Posted: Thu Jan 11, 2007 7:13 pm
by vn70072
Interesting. Still, it's been funny like that since I started. I wonder if it was just considered too minor to bother with or something.
Posted: Thu Jan 11, 2007 7:31 pm
by Sub_Zero
Yeah, it's not that it's very important, but can be annoying sometimes, and it is easy to fix.
For example if you are posting an ingame nick or alliance name with a special character like ™ or Ω, not to mention the slashes infront of an aphostrophe or quotation mark

Re: slashes and html in messages
Posted: Fri Jan 12, 2007 8:12 am
by RobinInDaHood
Sub_Zero wrote:Hey
You have a bug in your message system.....
The recieved message shows slashes and screwed up html codes....
The solution is to add this to the code:
Code: Select all
$message = htmlentities(stripslashes($message));
That's all...
It would be nice if you'd also do the following:
Code: Select all
$message = str_replace("\n", "<br>", $message);
That would maintain newlines in the messages and not run everything together into one contiguous line. This line would have to be inserted after the htmlentities() call above otherwise the <br> tags would be rendered as text.
Posted: Fri Jan 12, 2007 8:24 am
by Legoless
Or just use phpBB BBCode class and everything is solved.

Re: slashes and html in messages
Posted: Fri Jan 12, 2007 9:53 am
by Inferno™
RobinInDaHood wrote:Sub_Zero wrote:Hey
You have a bug in your message system.....
The recieved message shows slashes and screwed up html codes....
The solution is to add this to the code:
Code: Select all
$message = htmlentities(stripslashes($message));
That's all...
It would be nice if you'd also do the following:
Code: Select all
$message = str_replace("\n", "<br>", $message);
That would maintain newlines in the messages and not run everything together into one contiguous line. This line would have to be inserted after the htmlentities() call above otherwise the <br> tags would be rendered as text.
Its fixed so paragraphs are now possible. Dont you use the message system?
Re: slashes and html in messages
Posted: Fri Jan 12, 2007 11:08 am
by RobinInDaHood
Inferno™ wrote:Its fixed so paragraphs are now possible. Dont you use the message system?
Actually, not much because of its limitations. If what you're saying is correct, it's a step in the right direction of making a more usable tool.
Re: slashes and html in messages
Posted: Fri Jan 12, 2007 6:33 pm
by Sub_Zero
It would be nice if you'd also do the following:
Code: Select all
$message = str_replace("\n", "<br>", $message);
That would maintain newlines in the messages and not run everything together into one contiguous line. This line would have to be inserted after the htmlentities() call above otherwise the <br> tags would be rendered as text.
Going into details, I obviously forgot to mention that the htmlentities function also replaces the "<" and ">" in tags, so the line:
Code: Select all
$message = htmlentities(stripslashes($message));
has to be placed
before any nl2br() function call, eg. remove any existing nl2br() call and do this:
Code: Select all
$message = str_replace("\n", "<br />\n",htmlentities(stripslashes($message)));
Which would maintain the newlines and not corrupt the tags into html text.