Don't chunk_split encoded image string.

Don't return json error but null if card can't be parsed.
Small check for non-parsable card in index.php.
remotes/origin/stable
Thomas Tanghus 13 years ago
parent 22356533a0
commit e60860148c
  1. 10
      apps/contacts/index.php
  2. 9
      apps/contacts/lib/app.php
  3. 2
      lib/image.php

@ -44,19 +44,17 @@ OC_App::setActiveNavigationEntry( 'contacts_index' );
$id = isset( $_GET['id'] ) ? $_GET['id'] : null; $id = isset( $_GET['id'] ) ? $_GET['id'] : null;
$details = array(); $details = array();
// FIXME: This cannot work..?
if(is_null($id) && count($contacts) > 0) { if(is_null($id) && count($contacts) > 0) {
$id = $contacts[0]['id']; $id = $contacts[0]['id'];
} }
$vcard = null;
$details = null;
if(!is_null($id)) { if(!is_null($id)) {
$vcard = OC_Contacts_App::getContactVCard($id); $vcard = OC_Contacts_App::getContactVCard($id);
if(!is_null($vcard) {
$details = OC_Contacts_VCard::structureContact($vcard); $details = OC_Contacts_VCard::structureContact($vcard);
} }
// if( !is_null($id)/* || count($contacts)*/){ }
// if(is_null($id)) $id = $contacts[0]['id'];
// $vcard = OC_Contacts_App::getContactVCard($id);
// $details = OC_Contacts_VCard::structureContact($vcard);
// }
// Include Style and Script // Include Style and Script
OC_Util::addScript('contacts','interface'); OC_Util::addScript('contacts','interface');

@ -56,15 +56,14 @@ class OC_Contacts_App{
return $card; return $card;
} }
/**
* @brief Gets the VCard as text
* @returns The card or null if the card could not be parsed.
*/
public static function getContactVCard($id){ public static function getContactVCard($id){
$card = self::getContactObject( $id ); $card = self::getContactObject( $id );
$vcard = OC_VObject::parse($card['carddata']); $vcard = OC_VObject::parse($card['carddata']);
// Check if the card is valid
if(is_null($vcard)){
OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('vCard could not be read.'))));
exit();
}
return $vcard; return $vcard;
} }

@ -196,7 +196,7 @@ class OC_Image {
if (!$res) { if (!$res) {
OC_Log::write('core','OC_Image::_string. Error writing image',OC_Log::ERROR); OC_Log::write('core','OC_Image::_string. Error writing image',OC_Log::ERROR);
} }
return chunk_split(base64_encode(ob_get_clean())); return base64_encode(ob_get_clean());
} }
/** /**

Loading…
Cancel
Save