Topic: Smiley problem

Hi.... You might have seen this problem before..
My smileys contain characters like ] > and < and this seems to mess up the smilies by putting an "> -string right after the smiley-icon for some of the smileys, but not necessarliy those which contain these symbols. After a lot of experimenting I've located the source of the error (I think) to the ALT-attribute in the IMAGE-tag for the smiley icons. It seems like the ALT-attribute is truncated at the first dbl-quote character and thus autumatically tries to complete the string with "> which is then unfortunately displayed in those posts.
By removing the $smiley_text[$i] part in the ALT-attribute the problem ceased to haunt me. I change was made in the file parser.php at line 284 for me, but it ought to be about 10 rows (or so) higher up for most people. It is inside the do_smileys($message) -function.

So... could this give rise to any problems as a result of this change?
If so... is there any other means to get rid of this annoying problem?

No electrons were harmed in the creation of this post.
However, many were excited and some may have enjoyed the experience.

2 (edited by Razmooze 2004-06-26 19:11)

Re: Smiley problem

For example... the smiley ]:) would appear like this:
http://www.smyrnakyrkan.se/punbb/upload/img/smilies/evil.png">

No electrons were harmed in the creation of this post.
However, many were excited and some may have enjoyed the experience.

Re: Smiley problem

I know why that happens. The problem is that when the smiley text is inserted in the alt attribute, the next iteration, that smiley text will be interpreted as a new smiliey and all hell breaks loose. A possible solution is to not allow a smiley to be surrounded by doublequotes. Ill look into it.

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

Re: Smiley problem

oh.. thx!

No electrons were harmed in the creation of this post.
However, many were excited and some may have enjoyed the experience.

5 (edited by Razmooze 2004-06-26 23:28)

Re: Smiley problem

Wouldn't it be possible to force the admin to use html-characters in the smiley_text-array instead? Could that be a solution for this "special case"?
Like:
>:(   for an angry smiley  >:(

No electrons were harmed in the creation of this post.
However, many were excited and some may have enjoyed the experience.

Re: Smiley problem

How would that help?

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

7 (edited by Razmooze 2004-06-27 23:23)

Re: Smiley problem

Well, it seemed like that when the actual characters ] and > were used... the tag would look like this (with the case of the smiley ]:))

...
<img src="smiley.png" width="15" height="15" alt="]
...

it seems like it tries to use "]" as a end-tag character..

No electrons were harmed in the creation of this post.
However, many were excited and some may have enjoyed the experience.

Re: Smiley problem

Fixed. I can't find a really good solution to the problem though. The problem arises when you have two smilies where one of the smilies is a "subset" of a previous smiley. Eg. if you had ]:) and :), you would encounter problems. The result is this:

<img src="img/smilies/evil.png" width="15" height="15" alt="]<img src="img/smilies/smile.png" width="15" height="15" alt=":)" />" />

As you can see, the alt text for the evil smiley is interpreted as a new smiley (a regular smile). The only simple and fast solution I can come up with is not having the smiley text in the alt attribute. What to put in the alt tag is another story. An empty alt attribute isn't good from an accessibility standpoint, but then again, neither is just putting "Smile" in there. I honestly don't know what to do about this. Suggestions?

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

Re: Smiley problem

Instead of putting the symbol in the alt tag, put the name of the smilie, i.e, evil, laughing, happy, grin, sad, etc.  That should resolve this issue I would think.

Re: Smiley problem

I've considered that as well. It would mean adding a third array that contains the name of the smiliey. Either that or using the filename and stripping out the suffix (e.g. .png, .gif). It adds a bit of processing though.

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

11 (edited by Frank H 2004-09-03 11:55)

Re: Smiley problem

from the top of my head ... (use a very similar thing on my attachment mod, to get extension wink)

substr($filename,0,strrpos($filename,'.'))
(put it in my iterator ... 47 microseconds per command on my dual P2 celeron 300@450mhz, twice as long as date("T") takes wink)

Re: Smiley problem

I guess we can live with that :)

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