Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nick/Host lookups should be case-insensitive #11

Open
khaytsus opened this issue Sep 11, 2013 · 4 comments
Open

Nick/Host lookups should be case-insensitive #11

khaytsus opened this issue Sep 11, 2013 · 4 comments

Comments

@khaytsus
Copy link

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(?) " );

@IsaacG
Copy link
Collaborator

IsaacG commented Sep 12, 2013

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

@khaytsus
Copy link
Author

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.

@symkat
Copy link
Owner

symkat commented Sep 14, 2013

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

@khaytsus
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants