shizmob / pydle

An IRCv3-compliant Python 3 IRC library.
BSD 3-Clause "New" or "Revised" License
154 stars 48 forks source link

Non-Key-Value Tags cause AttributeError #173

Closed Rixxan closed 2 years ago

Rixxan commented 2 years ago

Tags in Messages that are not simple key-value tags (Such as the draft/bot tag in unrealircd) cause an AttributeError to be thrown due to out-of-spec handling of tagged messages.

Reference to example breaking tag: https://github.com/unrealircd/unrealircd/blob/893bf864f6c616e891d84916d27e342c252f31aa/src/modules/bot-tag.c (Added to message as the tag draft/bot;) will cause an exception that is not properly handled and cause the bot to lock up.

Environment:

theunkn0wn1 commented 2 years ago

Able to reproduce in isolation, I am testing a fix.

Looks like the processing logic for empty tags / tags lacking a value is incorrect.

Pydle sets empty tags to the value True. The problem arises when the following logic, which evaluates escape sequences, attempts to operate over these empty tags. That logic assumes the value is a string, but its a boolean in this case.

A solution here would be to skip escape sequence processing in this scenario.

theunkn0wn1 commented 2 years ago

Reading into the Tag specification, Implementations MUST interpret empty tag values (e.g. foo=) as equivalent to missing tag values (e.g. foo)

Pydle cannot set missing tag values to boolean True, since that would diverge from the behavior of the missing case.

A solution here would be, as per the spec, interpret missing as empty and assign a value of "".

This would change pydle behavior, although It should be reverse compatible as long as downstreams only depend on the truthiness checks.

theunkn0wn1 commented 2 years ago

Duplicate of #148 I will orchestrate a release today containing this fix.

Rixxan commented 2 years ago

Update: was fixed by unreleased change in https://github.com/Shizmob/pydle/commit/60820 a while ago.

Closing as already fixed, should be solved in upcoming Pydle release hopefully!