Issue information

Issue ID
#4700
Status
Fixed
Severity
Fair
Started
Hercules Elf Bot
Jan 8, 2011 20:29
Last Post
Hercules Elf Bot
Apr 19, 2012 9:23
Confirmation
Yes (1)
No (0)

Hercules Elf Bot - Jan 8, 2011 20:29

Originally posted by [b]EternalFriend[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4700

Hello.
First encountered this problem - create a character with the same nicknames, which in turn are written differently:
TEST, Test, test, teSt - I can create.
In char_athena.conf - as it should - ban:
CODE
// Allow or not identical name for characters but with a different case (upper/lower):
// example: Test-test-TEST-TesT; Value: 0 not allowed (default), 1 allowed
name_ignoring_case: no

Tried to put a value of zero, the effect is not produced.
tried to put the latest on this day (14659) - the same thing.
Different keyboard layouts are excluded.

Sorry for my english, I'm from Russia.
Thx.

Hercules Elf Bot - Dec 25, 2011 18:29

Originally posted by [b]xazax[/b]
The value is read in char server sql implementation, but not used.

My solution, ( I did not test it yet ):

[codebox]
Index: char.c
===================================================================
--- char.c (revision 15270)
+++ char.c (working copy)
@@ -1327,11 +1327,31 @@
}

// check name (already in use?)
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) )
+ if ( name_ignoring_case )
{
- Sql_ShowDebug(sql_handle);
- return -2;
+ if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) )
+ {
+ Sql_ShowDebug(sql_handle);
+ return -2;
+ }
}
+ else
+ {
+ char lower_esc_name[NAME_LENGTH*2+1];
+ int i = 0;
+
+ while(esc_name[i])
+ {
+ lower_esc_name[i] = tolower(esc_name[i]);
+ ++i;
+ }
+
+ if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE LOWER(`name`) = '%s' LIMIT 1", char_db, lower_esc_name) )
+ {
+ Sql_ShowDebug(sql_handle);
+ return -2;
+ }
+ }
if( Sql_NumRows(sql_handle) > 0 )
return -1; // name already exists


[/codebox]

This post has been edited by xazax on Dec 25, 2011 20:04

Hercules Elf Bot - Dec 30, 2011 1:35

Originally posted by [b]arp[/b]
I've had a chat to xazax about this, and unfortunately his above provided is a little wrong. I've spent a little while looking at this, and have provided a patch that I'm confident will work as intended. It turns out that the piece of code used to lower() a string actually ended up adding garbage on to strings of len(str)==4.

I can't find an attach button, so here's the diff:
[url="http://bawx.depha.se/.rathena/issue_4700.diff"]http://bawx.depha.se/.rathena/issue_4700.diff[/url]

Hercules Elf Bot - Dec 30, 2011 13:38

Originally posted by [b]Ind[/b]
[quote name='arp' timestamp='1325208912' post='6215']
I've had a chat to xazax about this, and unfortunately his above provided is a little wrong. I've spent a little while looking at this, and have provided a patch that I'm confident will work as intended. It turns out that the piece of code used to lower() a string actually ended up adding garbage on to strings of len(str)==4.I can't find an attach button, so here's the diff:[url="http://bawx.depha.se/.rathena/issue_4700.diff"]http://bawx.depha.se...issue_4700.diff[/url]
[/quote]
yours is a little wrong too XD I didn't test either yet but at taking a glance at the diff file, for example, you declare a lower_esc_name which is not used anywhere

Hercules Elf Bot - Dec 30, 2011 14:10

Originally posted by [b]arp[/b]
Ah, I must have missed that out, lower_esc_name is from the old code and I forgot to remove it, I'll attach an updated diff.

Hercules Elf Bot - Dec 30, 2011 17:52

Originally posted by [b]arp[/b]
Diff has been updated to remove the two unused declarations.

Hercules Elf Bot - Jan 4, 2012 0:16

Originally posted by [b]Ind[/b]
I've got to this and I've fixed it simply by adding a 'BINARY `name` = <name>'. Fixed in [rev=15374]