#1429 Python Plugin: scan for non NULLs in print events

open
nobody
None
5
2010-02-07
2010-02-07
Adam Dane
No

XChat 2.8.6 on linux

When certain text events occur there may be NULL elements between non-NULLs. If there is, then the elements after the NULL element are unavailable to the script. The change is needed to the Util_BuildList function in python.c; currently that function scans forward until it finds a NULL and assumes that to be the end of the data.

An example of when a NULL may precede a non-NULL is when a QUIT occurs with no quit message. In this case the host is unavailable to the script because the word data only contains the nickname (normally the word = [nickname, reason, host], in this case it will just be [nickname]).

The following is a comment from the equivalent section of the perl plugin (print_cb in perl.c), which illuminates the problem and solution:

/* need to scan backwards to find the index of the last element since some
events such as "DCC Timeout" can have NULL elements in between non NULL
elements */

Thanks.

Discussion

  • Adam Dane
    Adam Dane
    2011-05-12

    Proposed patch for issue.

     
  • Adam Dane
    Adam Dane
    2011-05-12

    Proposed patch solves the issue for me. Modifies Util_BuildList to find the last-valid member of the array and replace intermediate NULLs with Nones in the list. Adds Util_BuildEOLList to build the word_eol_list for the print callback. Modifies calls to Util_BuildList appropriately and removes code that's no longer needed from Callback_Print.

    Please let me know if format, code style, or other changes are needed to the patch.

    Thanks.

     
  • Adam Dane
    Adam Dane
    2012-10-08

    Script to reproduce the issue.

     
    Attachments
  • Adam Dane
    Adam Dane
    2012-10-08

    Attaching a script that easily reproduces the issue. With the script, one can see a difference between:

    (Join a test channel)
    /recv :foo!bar@baz.qux JOIN #channel
    /recv :foo!bar@baz.qux QUIT

    and:

    (Join a test channel)
    /recv :foo!bar@baz.qux JOIN #channel
    /recv :foo!bar@baz.qux QUIT :message

    The first will receive/print a one-element list, and the second will get a three-element list, where the last is the user host.