scripts icon indicating copy to clipboard operation
scripts copied to clipboard

emoji_aliases.py 1.0.2: broken replacement mechanism produces invalid IRC protocol messages

Open sim642 opened this issue 8 years ago • 0 comments

emoji.lua script provides the same functionality but is free of the issues described here and is thus recommended instead of this script.

Incoming line like (hypothetical)

:nick!user@123:101:ffff QUIT :my quit message

is replaced with

:nick!user@123💯 ffff QUIT :my quit message

which causes the ffff part of the host to be in IRC command's position instead of the QUIT.

This causes errors like

irc: command "ffff" not found

There are numerous problems in the script:

  1. Splitting on : blindly attempts to find the prefix (:my quit message) of the IRC message but : may appear in varying counts before that as seen with IPv6 hosts. In fact the entire existing split process is incorrect in this case because the splitting only excludes the initial : of the prefix. Correct IRC message parsing should be only done with irc_message_parse to ensure correctness.
  2. Space is added by replacement string causing it to incorrectly split into multiple IRC protocol arguments. If the space would not be added, the IRC message would still be (possibly) valid although contain emoji in the host (nick!user@123💯ffff).
  3. aliases_found attempts to only aliases found in the relevant parts of the IRC message but later they are still replaced on the entire string. This means that even if problem 1 was fixed and the parsing would be right for aliases_found, the script could misbehave the same way. This can happen when the alias found in the message also exists earlier in the IRC message (e.g. the host) and thus is actually replaced there and not in the originally found position for aliases_found.

sim642 avatar Jul 27 '17 08:07 sim642