Opened 11 years ago

Last modified 11 years ago

#1274 new Defect

emoticons are displayed twice

Reported by: d9pouces Owned by: timothy
Component: Colloquy (Mac) Version: 2.1 (Mac)
Severity: Minor Keywords: custom emoticons
Cc:

Description

I've created a new set of emoticons, and many of them are of the form ‘ #smiley# ‘

When I try to display, say, #sick#, I've the right picture, but displayed twice.
Emoticons like :) or :( are correctly displayed.

Change History (3)

comment:1 follow-up: Changed 11 years ago by d9pouces

It seems to be a parsing bug

If the smiley is #roll#, then the generated HTML looks like


    <span class="emoticon roll">
        <samp>
          <a href="irc://irc.worldnet.net/#roll">#roll</a>
        </samp>
      </span>
      <span class="emoticon roll">
        <samp>#</samp>
      </span>

Instead of

    <span class="emoticon roll">
        <samp>
          <a href="irc://irc.worldnet.net/#roll">#roll#</a>
        </samp>
      </span>

comment:2 in reply to: ↑ description Changed 11 years ago by kim

Replying to d9pouces:

I've created a new set of emoticons, and many of them are of the form ‘ #smiley# ‘

When I try to display, say, #sick#, I've the right picture, but displayed twice.
Emoticons like :) or :( are correctly displayed.

looks like I found the problem.

in JVDirectChatPanel.m:

if( ! [[NSUserDefaults standardUserDefaults] boolForKey:@"MVChatDisableLinkHighlighting"] ) {

[messageString makeLinkAttributesAutomatically];
[self _hyperlinkRoomNames:messageString];

}


[[self emoticons] performEmoticonSubstitution:messageString];

now as #toto is a roomname (anyway I found in _hyperlinkRoomNames that #deface (for example) isn't a valid roomname... why are HTML colors > room names?

so, #toto as now a roomname attribute (url in irc://...)
then in emoticonsub, you match #toto# but #toto already has XHTMLStart and XHTMLEnd attributes, so it appends emoticon's html tags to them, which is good.

#airplane#
gives:
<a href="irc://.../airplane">#airplane</a>
then it also gives:
<span ...><samp>#airplane#</samp></span>

hey, but you already have a start & end attribute here!
-> to solve the problem, it seems to add:
</samp></span><span class="emoticon airplane"><samp>
right after the </a> of the roomname link.

now to solve it, what about doing this:

do first the link check
then, do the emoticon check. * prevent emots if there already are some attributes on the string * (maybe attributedSubstringFromRange should help in that)
finally do the roomname check. same as before, prevent attribute creation if there are already some attributes.

anyway I'm more than a newbie guy on cocoa programming so I'm not sure that I'm true, and I'm not fluent enough to propose a patch :(

comment:3 in reply to: ↑ 1 Changed 11 years ago by kim

Replying to d9pouces:

It seems to be a parsing bug

If the smiley is #roll#, then the generated HTML looks like


Instead of

    <span class="emoticon roll">
        <samp>
          <a href="irc://irc.worldnet.net/#roll">#roll#</a>
        </samp>
      </span>

Anyway I'm not sure that's true, it should be:

    <span class="emoticon roll">
        <samp>
          #roll#
        </samp>
      </span>

the URI link is only for the roomnames, and having a # in the room name (except the first # of course) isn't valid.

Note: See TracTickets for help on using tickets.