Closed silentwings closed 5 years ago
Easiest way to reproduce: send e.g. "GETUSERINFO [fx]bluestone" when [Fx]Bluestone is offline (if the client requested is online, but case is incorrect, there will be a crash due to this bug!)
Calling this with username=='[fx]bluestone' returns the offline client with username [Fx]Bluestone
doesn't that mean, that the search is case sensitive but the search should be case insensitive?
https://stackoverflow.com/questions/16573095/case-insensitive-flask-sqlalchemy-query
->
.query.filter(Model.column.ilike("ganye"))
-> entry = self.sess().query(User).filter(User.username.ilike(username)).first()
should do the trick (untested)
from sqlalchemy import func entry = self.sess().query(User).filter(User.username == func.binary(username)).first()
https://www.oreilly.com/library/view/mysql-cookbook/0596001452/ch04s10.html "String comparisons in MySQL are not case sensitive by default:" This seems a legitimate case in which to blame MS...
Same convention in http://underpop.free.fr/m/mysql/teach-yourself/using-operators-with-strings.html for mariadb
Seems the issue also exists in SQLAlchemy; our col types are wrong, utf8 defaults to utf8_general_ci which is case insensitive, and utf8_general_cs is needed for case sensitivity
Not sure which is best
resolution is that:
note that whether db is case sensitive or not is OS dependent, we correctly handle either possibility
for example, in SQLUsers.UsersHandler
Calling this with username=='[fx]bluestone' returns the offline client with username [Fx]Bluestone
On the Python side (e.g. using == with DataHandler.usernames) there is case sensitivity
This likely causes inconsistencies