twisted / twisted

Event-driven networking engine written in Python.
https://www.twisted.org
Other
5.44k stars 1.14k forks source link

Accept current reality of CTCP protocol. #11022

Open twisted-trac opened 18 years ago

twisted-trac commented 18 years ago
gnuk's avatar gnuk reported
Trac ID trac#1335
Type defect
Created 2005-11-19 22:53:24Z

Attachments:

Searchable metadata ``` trac-id__1335 1335 type__defect defect reporter__gnuk gnuk priority__high high milestone__ branch__ branch_author__ status__new new resolution__ component__words words keywords__ time__1132440804000000 1132440804000000 changetime__1205777175000000 1205777175000000 version__ owner__nullie nullie cc__exarkun cc__gnuk ```
twisted-trac commented 16 years ago
exarkun's avatar @exarkun set owner to nullie

This seems like it might be a good improvement to make. The change should be backwards compatible, though. That means deleting all those functions shouldn't happen and the signature change should be avoided. There's also a problem with communicating with freenode with this patch -- parsing the message into two parts in ctcpParse sometimes fails with a TypeError.

twisted-trac commented 18 years ago
gnuk's avatar gnuk commented
#!html
<pre>
Hello,
I use twisted.words for an irc log bot.
I join a peace of code whose get mistake meet error,
based on example ircLogBot.py 
(http://twistedmatrix.com/projects/words/documentation/examples/ircLogBot.py).

Bot connect to server and join a channel, and when an user say :
"foobar \o/", log's bot indicate :
"2005/11/12 20:23 CET [LogBot,client] raw data from privmsg :  foobar \o/",

but when an user say : 
"/me foobar \o/", an action, log's bot indicate :
"2005/11/12 20:23 CET [LogBot,client] raw data from action :  foobar o/",
escape character « \ » (in python) disapear.

If an user say :
"/me foobar \\o/", always an action, but with additional escape character,
log's bot indicate : 
"2005/11/12 20:23 CET [LogBot,client] raw data from action :  foobar \o/".

I think it's just an error with escape characters in basic.LineReceiver, but I
don't find
any mistake in source.

Thanks,
Sorry for my poor english.
</pre>
twisted-trac commented 16 years ago
nullie's avatar nullie commented

I've attached a patch with a test case. Waiting for review.

twisted-trac commented 16 years ago
nullie's avatar nullie commented

Ok. I've figured out that this due to ctcp quoting and dequoting. According to http://www.irchelp.org/irchelp/rfc/ctcpspec.html, extended messages (and ACTION is extended message), must be quoted, using backslash ("\") as escape character. And Twisted respects this in both directions (quoting and dequoting). But most (all? I tried X-Chat, epic4, inettool (mobile client)) conventional IRC clients don't quote and dequote ACTION ctcp messages.

Should we add special handling for ACTION ctcp message?

twisted-trac commented 16 years ago
nullie's avatar nullie commented

http://www.irchelp.org/irchelp/rfc/index.html says that more current ctcp specification, adopted by major irc client is at: http://www.invlogic.com/irc/ctcp.html But that document is confusing on subject of CTCP high-level quoting. Maybe we should consider quoting only X-DELIM to be safe.

twisted-trac commented 16 years ago
nullie's avatar nullie commented

I've also found this: http://www.invlogic.com/irc/ctcp2_3.html

twisted-trac commented 16 years ago
nullie's avatar nullie commented

http://www.kvirc.de/docu/doc_ctcp_handling.html has a nice view. Current implementation in Twisted incorporates part of that approach.

We may assume there is only one CTCP extended message in IRC message and forget about CTCP quoting, only adopting practices of current clients to be compatible with them.

twisted-trac commented 16 years ago
chewy's avatar chewy commented

Also, you probably want to run the included test in twisted/doc/words/examples/ircLogBot.py against the patched sources. With the last patch, I got a tuple unpack error in ctcpParse