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

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

grim
pidgin/pidgin
default
pidgin
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host

Ran the unit tests under valgrind

Summary
IRCv3: add ircv3_source_parse to parse sources into nick, user, and host
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. Should this be anchored, or use match_full?

  3. libpurple/protocols/ircv3/tests/test_ircv3_source.c (Diff revision 1)
     
     
     
     
     
     

    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..)

  4. 
      
grim
grim
grim
Review request changed

Change Summary:

tweaked the regex to not allow ! and @ in servernames and added a few more bad example unit tests.

Commits:

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

Diff:

Revision 4 (+596)

Show changes

Loading...