Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various iCloud vCard issues, add fallback for external photos #4617

Closed
rcubetrac opened this issue Jul 21, 2014 · 5 comments
Closed

Various iCloud vCard issues, add fallback for external photos #4617

rcubetrac opened this issue Jul 21, 2014 · 5 comments

Comments

@rcubetrac
Copy link

Reported by rosali on 21 Jul 2014 04:12 UTC as Trac ticket #1489993

Apple iCloud vcards contain an URL as Photo data, f.e.:

VERSION:3.0
PHOTO;ENCODING=B:aHR0cHM6Ly9w ... masked ... MWVjYWU0ZTM1NjZiN2Q2MThkMjY=

In this case the photo display in preview pane and mail view fails.

Possible fix:

./program/steps/addressbook/photo.inc ::: line 67ff.

// let plugins do fancy things with contact photos
$plugin = $RCMAIL->plugins->exec_hook('contact_photo',
    array('record' => $record, 'email' => $email, 'data' => $data));

// check if data is an URL
if (filter_var($data, FILTER_VALIDATE_URL)) {
    $plugin['url'] = $data;
}

Migrated-From: http://trac.roundcube.net/ticket/1489993

@rcubetrac
Copy link
Author

Comment by rosali on 21 Jul 2014 05:51 UTC

There is an additional issue:

iCloud photo URLs are protected by access control (authentication cookie must be present in browser). If the user is not logged in his iCloud account then photo display fails even after the above mentioned fix.

Possible solution:

./program/steps/mail/show.inc ::: line 349 ff.

    else {
        $photo_img = $placeholder ? $placeholder : 'program/resources/blank.gif';
    }

    $RCMAIL->output->add_script('$("<img />").error(function() { $("#contactphoto").children().remove() }).attr("src", "' . $photo_img . '");', 'foot');

./program/steps/addressbook/func.inc ::: line 806 ff.

    $img = html::img(array('src' => $photo_img, 'border' => 1, 'alt' => ''));
    $content = html::div($attrib, $img);

    $RCMAIL->output->add_script('$("<img />").error(function() { $("#contactpic").children().attr("src", "skins/' . $RCMAIL->config->get('skin', 'larry') . '/images/contactpic.png") }).attr("src", "' . $photo_img . '");', 'foot');

Read more about the fix @ http://stackoverflow.com/questions/1977871/check-if-an-image-is-loaded-no-errors-in-javascript

@rcubetrac
Copy link
Author

Comment by rosali on 21 Jul 2014 07:18 UTC

Additional issue with iCloud vcards.

rcube_vcard class, method cleanup is missing case in-sensitive modifier ("i"). The result is that uppercase "ITEM..." fields are not converted to regulare field names.

Example:

ITEM1.ADR;TYPE=HOME;TYPE=pref:;;12345 NW 78CT;Hialeah;FL;3329;United States;

--> Result: Address is not displayed

Suggested fix:

./program/lib/Roundcube/rcube_vcard.php ::: line 535 ff:

        $vcard = preg_replace(array(
                // convert special types (like Skype) to normal type='skype' classes with this simple regex ;)
                '/item(\d+)\.(TEL|EMAIL|URL)([^:]*?):(.*?)item\1.X-ABLabel:(?:_\$!<)?([\w-() ]*)(?:>!\$_)?./si',
                '/^item\d*\.X-AB.*$/mi',  // remove cruft like item1.X-AB*
                '/^item\d*\./mi',         // remove item1.ADR instead of ADR
                '/\n+/',                 // remove empty lines
                '/^(N:[^;\R]*)$/m',      // if N doesn't have any semicolons, add some
            ),
            array(
                '\2;type=\5\3:\4',
                '',
                '',
                "\n",
                '\1;;;;',
            ), $vcard);

@rcubetrac
Copy link
Author

Comment by @alecpl on 1 Aug 2014 10:53 UTC

Fixed in fcb7d4f

@rcubetrac
Copy link
Author

Status changed by @alecpl on 1 Aug 2014 10:53 UTC

new => closed

@rcubetrac
Copy link
Author

Summary changed by @alecpl on 1 Aug 2014 10:53 UTC

iCloud vcards

Various iCloud vCard issues, add fallback for external photos

@rcubetrac rcubetrac added this to the 1.0.3 milestone Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant