Bug 2479 - LDIF address book import matches tags case sensitive
Summary: LDIF address book import matches tags case sensitive
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: UI/Address Book (show other bugs)
Version: 3.7.9
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2011-08-28 12:30 UTC by Bodo Graumann
Modified: 2011-10-20 20:22 UTC (History)
0 users

See Also:


Attachments
case insensitive LDIF tag matching in ldif.c (2.69 KB, patch)
2011-08-28 12:30 UTC, Bodo Graumann
no flags Details | Diff
case insensitive check, patch 2 (2.76 KB, text/plain)
2011-08-28 16:23 UTC, Paul
no flags Details
case insensitive LDIF tag matching in ldif.c, shorter (2.98 KB, patch)
2011-08-28 20:56 UTC, Bodo Graumann
no flags Details | Diff

Description Bodo Graumann 2011-08-28 12:30:07 UTC
Created attachment 1000 [details]
case insensitive LDIF tag matching in ldif.c

When importing an address book in LDIFormat, certain tags (or AttributeTypes) are matched against known fields like firstname, lastname, etc. [ldif_hash_add_list(...); ldif_add_value(...)].
I noticed that when I import a certain file, the first name is not detected (anymore). The reason for this seems to be, that somewhere between 3.7.3 and 3.7.9 you changed LDIF_TAG_FIRSTNAME from "givenname" to "givenName". While kdepim still exports it as "givenname".
If I read http://tools.ietf.org/html/rfc2849 [Page 2] and http://tools.ietf.org/html/rfc2251 [4.1.4] correctly, the tags should be case insensitive.
I'll attach a patch, which works for me.
Comment 1 Paul 2011-08-28 14:22:10 UTC
I am wondering why you chose to use g_utf8_strdown() in the patch rather than g_utf8_casefold()?
Comment 2 Bodo Graumann 2011-08-28 14:54:34 UTC
That has no deeper meaning. I think g_utf8_casefold will work just as well and even be shorter. My first idea was to change the constants in ldif.h to lowercase and only apply g_utf8_strdown to one argument, but now I rather only changed one file.
Comment 3 Paul 2011-08-28 16:21:48 UTC
I'm not able to test this, but my patch appears that it would achieve the same result and is a little less cluttered. If you can test it and report back then that would be appreciated.
Comment 4 Paul 2011-08-28 16:23:03 UTC
Created attachment 1001 [details]
case insensitive check, patch 2
Comment 5 Bodo Graumann 2011-08-28 19:35:58 UTC
If I read the documentation correctly even with g_utf8_casefold you would have to apply the conversion on both strings. Thus the only difference is using g_utf8_casefold in place of g_utf8_strdown and there would be the same amount of clutter.
Your patch misses to apply g_utf8_casefold to the user-string and won't work.
My only reference is http://scentric.net/tutorial/sec-sorting-string-nocase.html, where there is no elaboration on whether any of these two methods is better suited for the job, so I can't say anything about that...
If you want less clutter, you could define a function which combines conversion and comparison, but I would not know where claws-mail keeps such functions.
Comment 6 Paul 2011-08-28 20:22:52 UTC
> Your patch misses to apply g_utf8_casefold to the user-string and won't work.

g_utf8_strdown() is applied to the string in both sections, (added by my patch to 2nd).

Did you test my patch?
Comment 7 Bodo Graumann 2011-08-28 20:56:22 UTC
Created attachment 1002 [details]
case insensitive LDIF tag matching in ldif.c, shorter

Ah ok, now I see what you are trying to do. That is of course a good idea. But according to the documentation g_utf8_strdown returns the conversed string and does not do an in place operation. Also you have to either use strdown or casefold in both places, because they are not compatible.
What also wonders me is that there already is a line 'g_utf8_strdown( nm, -1 );' which would not actually do anything. So I'm attaching a new patch, which incorporates your idea.
Comment 8 users 2011-10-20 20:20:35 UTC
Changes related to this bug have been committed.
Please check latest CVS and update the bug accordingly.
You can also get the patch from:
http://www.colino.net/claws-mail/

2011-10-20 [paul]	3.7.10cvs39

	* AUTHORS
	* src/ldif.c
	* src/gtk/authors.h
		fix bug 2479, 'LDIF address book import matches tags case sensitive'
		Patch by Bodo Graumann <mail@bodograumann.de>

Note You need to log in before you can comment on or make changes to this bug.