Stalker icon indicating copy to clipboard operation
Stalker copied to clipboard

Nick/Host lookups should be case-insensitive

Open khaytsus opened this issue 12 years ago • 4 comments

Using /nick_lookup is currently case sensitive and fails to find a user when the case is not exact. I have locally kludged this, but don't think this is the best solution.

in _get_hosts_from_nick $sth = $DBH->prepare( "SELECT nick, host FROM records WHERE nick = lower(?) " );

khaytsus avatar Sep 11 '13 14:09 khaytsus

I'm not convinced this is the correct behaviour. If we do go this router, I'd suggest having the script run all incoming adds and lookups through a lc() and not having the SQL do the lower().

IsaacG avatar Sep 12 '13 02:09 IsaacG

I probably should have just logged the bug and left my kludgy code out of it :-) Please feel free to fix any way you think is best.

khaytsus avatar Sep 12 '13 02:09 khaytsus

I agree that it should be case-insensitive. IRC itself is case-insensitive when it comes to the protocol, but the display logic preserves case (at least on any IRC server I've ever been on). However, I have seen networks without services where multiple unique users share the same nickname and come and go at different times -- hostnames and the capitalization being the only real differentiating factors.

I would side on a two-fold solution:

  • Give the user the option with a setting like stalker_case_insensitive_search and default to true
  • Use the SQLite lower function as opposed to changing records as they come in, this allows the setting to be changed arbitrarily without impacting the DB's records (or requiring more initialization code to add the upgrade and fix old records).

Correct me if I'm wrong, but I believe the correct syntax for that SQL would be more like:

$sth = $DBH->prepare( "SELECT nick, host FROM records WHERE lower(nick) = ?" );
$sth->execute( lc($query) );

symkat avatar Sep 14 '13 06:09 symkat

You're right, that syntax is correct for exact matches, I think I pasted my partial match code section. Oops :) And I agree with the config part, on smaller networks this could be something someone would want although these days I'm "only" on about 4 large ones, all with services.

khaytsus avatar Sep 14 '13 14:09 khaytsus