connectivity/source/drivers/macab/MacabRecords.cxx |   22 +++++++++++++++++++++
 1 file changed, 22 insertions(+)

New commits:
commit 15ee3a463768810b438d558533a3baca0700d690
Author:     Dan Williams <d...@ioncontrol.co>
AuthorDate: Tue Sep 16 21:20:08 2025 -0500
Commit:     Patrick Luby <guibomac...@gmail.com>
CommitDate: Sun Sep 21 15:26:37 2025 +0200

    connectivity/macab: avoid errors due to missing contacts.notes entitlement
    
    Accessing an address book contact's Note field requires an entitlement since
    Mac OS 13. Without that entitlement the following error occurs:
    
    CoreData: error: Unhandled error occurred during faulting: Error 
Domain=NSCocoaErrorDomain Code=134092 "(null)"
    
    It seems unlikely that the Note field functionality is widely used for
    anything the address book functionality is used for, so just ignore the
    field entirely.
    
    Signed-off-by: Dan Williams <d...@ioncontrol.co>
    Change-Id: I694f3ac40a8dccb49f51818dcdb3da7948f560d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191057
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>
    Tested-by: Jenkins

diff --git a/connectivity/source/drivers/macab/MacabRecords.cxx 
b/connectivity/source/drivers/macab/MacabRecords.cxx
index eb812790a4bf..046427ab5879 100644
--- a/connectivity/source/drivers/macab/MacabRecords.cxx
+++ b/connectivity/source/drivers/macab/MacabRecords.cxx
@@ -321,6 +321,21 @@ void MacabRecords::bootstrap_requiredProperties()
         kABAddressProperty, kABPhoneProperty, kABEmailProperty};
 }
 
+bool shouldSkipProperty(CFStringRef propertyName)
+{
+    /* Skip Note property to help prevent the following exception:
+     *
+     * CoreData: error: Unhandled error occurred during faulting: Error 
Domain=NSCocoaErrorDomain Code=134092 "(null)"
+     *
+     * which occurs because we do not have an entitlement to access contact 
notes.
+     * See 
https://developer.apple.com/documentation/bundleresources/entitlements/com.apple.developer.contacts.notes
+     * for more details.
+     */
+    if (CFStringCompare(propertyName, CFSTR("Note"), 0) == kCFCompareEqualTo)
+        return true;
+
+    return false;
+}
 
 /* Create the header for a given record type and a given array of records.
  * Because the array of records and the record type are given, if you want
@@ -457,6 +472,9 @@ MacabHeader *MacabRecords::createHeaderForRecordType(const 
CFArrayRef _records,
         for(sal_Int32 j = 0; j < numNonRequiredProperties; j++)
         {
             property = nonRequiredProperties[j];
+            if (shouldSkipProperty(property))
+                continue;
+
             headerDataForProperty = 
createHeaderForProperty(record,property,_recordType,false);
             if(headerDataForProperty != nullptr)
             {
@@ -853,11 +871,15 @@ MacabRecord *MacabRecords::createMacabRecord(const 
ABRecordRef _abrecord, const
     for(i = 0; i < numProperties; i++)
     {
         propertyName = 
static_cast<CFStringRef>(CFArrayGetValueAtIndex(recordProperties, i));
+        if (shouldSkipProperty(propertyName))
+            continue;
+
         localizedPropertyName = ABCopyLocalizedPropertyOrLabel(propertyName);
         propertyNameString = CFStringToOUString(localizedPropertyName);
         CFRelease(localizedPropertyName);
 
         /* Get the property's value */
+
         propertyValue = ABRecordCopyValue(_abrecord,propertyName);
         if(propertyValue != nullptr)
         {

Reply via email to