roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.9k stars 1.64k forks source link

Contacts import: Contacts treated as duplicates despite differences in some fields #9592

Open respiranto opened 3 months ago

respiranto commented 3 months ago

Prerequisites

Describe the issue

When importing contacts from a vCard file that contains two vcard objects with the same e-mail address, or one vcard object with an e-mail address that is already assigned to an existing contact, the contacts are treated as duplicates and one of them is not imported, with the message "Skipped 1 existing entries: [...]".

This does not happen if "Replace the entire address book" is activated on importing.

I would expect that a contact is only skipped on import if it would be an exact duplicate of another contact.

Further, I would expect that duplicates within a file are treated the same regardless of whether "Replace the entire address book" is activated on importing.

Example (note that vCard mandates CRLF as newline sequence):

BEGIN:VCARD
VERSION:3.0
N:Doe;Jane;;;
FN:Jane Doe
EMAIL:doe@example.net
END:VCARD
BEGIN:VCARD
VERSION:3.0
N:Doe;John;;;
FN:John Doe
EMAIL:doe@example.net
END:VCARD

Result of importing above example:


Originally reported at the Debian BTS as Bug 1078776, where I was asked to report the bug here instead.

What browser(s) are you seeing the problem on?

Firefox

What version of PHP are you using?

v8.2

What version of Roundcube are you using?

master / 58721e3037671888f82d75fd8e91a8622405af45

JavaScript errors

No response

PHP errors

No response

pabzm commented 2 months ago

Fixed via https://github.com/roundcube/roundcubemail/pull/9606

respiranto commented 2 months ago

IMHO, #9606 does not fully solve this issue.

As written initially, I would expect only exact duplicates to be skipped (i.e.: same fields set, all fields equal).

pabzm commented 2 months ago

It solved the topic from the title of this issue, which I found to be a good step forward.

If you insist on your position please re-open and change the title or create a new issue.

respiranto commented 2 months ago

Title changed.

I seem not to be allowed to re-open the issue.

pabzm commented 1 month ago

One problem I see with importing cards despite identical name and email address is, that in the list of contacts we show those two: name and email address. So in that list the two contacts would not be distinguishable.

respiranto commented 1 month ago

I see the following options to handle this problem (two different objects with matching name and e-mail address(es)):

I think I prefer (b).

pabzm commented 1 month ago

To clarify: in (b) you would still import the almost-duplicate contact?

respiranto commented 1 month ago

To clarify: in (b) you would still import the almost-duplicate contact?

Yes.

pabzm commented 1 month ago

I would be fine with that and merge such a PR but won't do it myself in the foreseeable future.

@alecpl What do you think?

alecpl commented 1 month ago

The way it is implemented a contact is considered existing if another contact with same name OR email address exists. One could argue that should be "AND" not "OR".

Another story is what to do when a duplicate is found on import. One could argue that we need an option to choose from, as it could be: 1) skip, 2) replace, 3) merge (whatever that would mean), 4) add. A separate thing is informing the user what has been done.

That being said, I think current state is fine, but I would accept a pull request that implements such behavior selector(s) in the import dialog.

Also, you could argue that for duplicates in the import file itself you might want a separate solution, e.g. by checking for duplicates in it before attempting to import anything.