Bug 2835 - add_address() in addr_compl.c should allow a NULL name
Summary: add_address() in addr_compl.c should allow a NULL name
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: Other (show other bugs)
Version: 3.9.1
Hardware: PC Linux
: P3 minor
Assignee: users
Depends on:
Reported: 2012-12-09 04:03 CET by neels
Modified: 2012-12-15 09:22 CET (History)
1 user (show)

See Also:

Allow NULL name for address completion (576 bytes, patch)
2012-12-09 04:03 CET, neels
no flags Details | Diff
FYI, the mentioned patch for the address_keeper plugin (618 bytes, text/unidiff)
2012-12-09 04:07 CET, neels
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description neels 2012-12-09 04:03:01 CET
Created attachment 1204 [details]
Allow NULL name for address completion

For a caller of addrbook_add_contact() (like the address-keeper plugin), it is impossible to enter a new address with an empty name, so that it shows up in the address completion, without doing a complete addressbook reload (claws-mail restart).

addrbook_add_contact() via addritem_person_set_common_name() and mgu_replace_string() strips the name to NULL. However, a NULL name invariably triggers a condition in addr_compl.c:add_address(), causing the address to be dropped from the address completion cache:

-	if (!name || !address) {
-		if (address || nick || alias || !grp_emails) 
-			return -1;

I don't really understand the condition, especially when comparing it to what it was in 3.8.0.

A patch will follow which collapses the condition to something that seems to make sense, and which sets a NULL name to the empty string, as is expected in that code path.

This patch, along with a change that adds an address book refresh to the address keeper plugin, allows the plugin to immediately update address completion with new addresses.
Comment 1 neels 2012-12-09 04:07:54 CET
Created attachment 1205 [details]
FYI, the mentioned patch for the address_keeper plugin

(FYI, attached patch that applies to the address_keeper plugin. This is just related to the proposed change, but neither depends on the other.)
Comment 2 neels 2012-12-09 04:40:46 CET
I think my ML post has a much clearer description of what this is:


I was annoyed by the fact that the address keeper plugin fails to push
new addresses into the address completion immediately.
Basically, to get immediate updates working, the address-keeper plugin should refresh the address book [second attached patch]. But if the 'name' of the recipient is empty, claws-mail still drops it from address completion because of some obscure condition in addr_compl.c, and that's what my patch for claws-mail tries to fix [first attached patch]. With both patches applied, it works the way I'd expect it to, crossing fingers against any adverse effects.
Comment 3 users 2012-12-10 15:22:34 CET
Changes related to this bug have been committed.
Please check latest CVS and update the bug accordingly.
You can also get the patch from:

2012-12-10 [mones]	3.9.0cvs45

	* src/addr_compl.c
		Fix bug #2835 (core part) to allow NULL names which
		have an address