IRCv3: add ircv3_source_parse to parse sources into nick, user, and host

Review Request #2585 — Created Aug. 23, 2023 and submitted

Information

pidgin/pidgin
default

Reviewers

IRCv3: add ircv3_source_parse to parse sources into nick, user, and host

Ran the unit tests under valgrind

Summary ID
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
2a4be8dfeadc0f2c44c665af6c618914f7ca40ca
Description From Last Updated

s/as a/a/

QuLogicQuLogic

Should this be anchored, or use match_full?

QuLogicQuLogic

Tests seem to only be for happy path; wondering what is expected for invalid unparseable input?

QuLogicQuLogic
QuLogic
  1. 
      
  2. Show all issues

    s/as a/a/

  3. Show all issues

    Should this be anchored, or use match_full?

  4. libpurple/protocols/ircv3/tests/test_ircv3_source.c (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    Tests seem to only be for happy path; wondering what is expected for invalid unparseable input?

    1. What would imparsable input be? per the spec Invalid characters nick/server are NUL, CR, LF, SPACE, and chan type characters. NUL, CR, LF, and SPACE, are already handled by the main message regex, but I suppose since these are public api we should check for them as well. NUL isn't necessary as we don't have a length parameter. And chan type characters require parsing during connection which we can probably ignore for now.

      So tl;dr I'll add some tests for CR, LF, and SPACE.

    2. I guess something like if the nick has server characters in it, or vice versa. Maybe something with the separators reversed, e.g., nick@foo!user@server or nick!user@server!foo? I guess now that the regex is anchored, this sort of thing is less possible, but I'm not sure if they're outright barred?

    3. Per rfc1459 § 2.3.1 a servername is an rfc952 hostname whcihc means ! and @ are invalid. The modern irc spec is a bit more strict as well.

      rfc1459 also defines user as follows which matches with our nick handling.

         <user>       ::= <nonwhite> { <nonwhite> }
         <nonwhite>   ::= <any 8bit code except SPACE (0x20), NUL (0x0), CR
                           (0xd), and LF (0xa)>
      

      I can't find anything about user/username in the modern ircv3 spec, so fall back to nick rules which would still make it impossible for the parser to fail (i think..)

  5. 
      
grim
grim
grim
QuLogic
  1. Ship It!
  2. 
      
grim
Review request changed
Status:
Completed