Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

casemapping=ascii isn't handled correctly when nicks have rfc1459 characters in them #498

Open
SohumB opened this issue Aug 30, 2017 · 4 comments
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems.

Comments

@SohumB
Copy link
Contributor

SohumB commented Aug 30, 2017

I dunno if this is an issue in the bridge or not, given that it doesn't happen on freenode, for instance; but on one particular server, starting direct chats with irc users who have []s in their nicks fails (as in, theirnick[pc]).

Received an error on irc.server.com: err_nosuchnick
["mynick[pc]","theirnick{pc}","No such nick/channel"]

(Yes, that is {}s in the echo'd error.)

It doesn't seem to be an issue serverside, though, as sending a raw cmd works fine.

!cmd irc.server.com PRIVMSG theirnick[PC] :message

I'm kinda baffled as to what would be a before-irc-server issue that is still server specific. Any ideas as to where to keep digging?

@kegsay
Copy link
Member

kegsay commented Aug 30, 2017

It's likely that this server has different case mapping rules. In the IRC RFC, [ ] are the upper-case equivalents of { }, so they are semantically identical (when PMing nick{PC} it should go to the same user as nick[PC]). You can thank the Finns for that.

Because of IRC's Scandinavian origin, the characters {}|^ are
considered to be the lower case equivalents of the characters []~,
respectively. This is a critical issue when determining the
equivalence of two nicknames or channel names.

Needless to say, this is insane and people tried to fix this. The bridge does look for the ISUPPORT CASEMAPPING rules, but it's likely that this is either not set or is set incorrectly on this IRCd.

@SohumB
Copy link
Contributor Author

SohumB commented Aug 30, 2017

Ah, right! So it turns out the issue is that this function, https://github.com/matrix-org/matrix-appservice-irc/blob/master/lib/irc/formatting.js#L245 , defaults casemapping to rfc1459, regardless of the server's casemapping. And the only places it's called are https://github.com/matrix-org/matrix-appservice-irc/blob/master/lib/models/IrcRoom.js#L16 and https://github.com/matrix-org/matrix-appservice-irc/blob/master/lib/bridge/MatrixHandler.js#L1304, both of which never pass in a case mapping.

This is a problem on my server because it accurately reports CASEMAPPING=ascii, and not on freenode because freenode has CASEMAPPING=rfc1459.

@Mikaela Mikaela added the bug label Aug 31, 2017
@SohumB SohumB changed the title PMs to nicks with []s in them fail on one specific server casemapping=ascii isn't handled correctly when nicks have rfc1459 characters in them Sep 4, 2017
@Mikaela
Copy link
Contributor

Mikaela commented Sep 11, 2017

This seems to affect IRCnet where I am unable to message my IRC bot @_ircnet_]o[:irc.snt.utwente.nl as I immediately receive Received an error on irc.snt.utwente.nl: err_nosuchnick ["Mikaela-","}o{","No such nick/channel"].

If someone wants to test, the bot should reply to ping by saying pong.

@vranki
Copy link
Contributor

vranki commented Jan 13, 2022

Got hit by this when DM'ing user who has ^ in nick.

Quote from other user "I think most networks tell which mapping they use when you connect so it's possible to default to something like ASCII and use RFC if told by the network."

So I suppose the fix is:

  • Listen to server when connecting and store the CASEMAPPING value
  • When mapping mxid to IRC nick use this mapping

I'd put this on relatively high priority as it messes up DM's for some users in at least one of major IRC networks.

@justinbot justinbot added T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems. and removed bug labels May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems.
Projects
None yet
Development

No branches or pull requests

5 participants