Decompress LZF notes from Apple vCard

50 views Asked by At

I have vCards that were exported from the Contacts app of Mac OS X 10.8.2. From what I can tell, Apple exported the notes with RTF that was compressed with LZF and converted the compressed data to base 64 before exporting the vCard. I'm trying to restore an export but the current version (Sonoma 14.2.1) ignores the notes field of the vCard. (I sanitized the contact information but didn't touch the X-APPLE-OL-NOTE section.)

Here's an example vCard:

    BEGIN:VCARD
    VERSION:3.0
    PRODID:-//Apple Inc.//Mac OS X 10.8.2//EN
    N:;Jane;;;(Baker) Smith
    FN:Jane (Baker) Smith
    TEL;type=HOME;type=VOICE;type=pref:(123) 123-4567
    TEL;type=CELL;type=VOICE:(321) 321-7654
    item1.ADR;type=HOME;type=pref:;;123 Any Street;Any Town;XX;T1T 1T1;Canada
    item1.X-ABADR:ca
    UID:CZTL-07DB0A0E-002E-0202-FF32-00816
    X-ABUID:6EB029FB-BBBB-4242-A054-C5F4392245BD:ABPerson
    X-EVOLUTION-FILE-AS:Smith, Jane
    X-APPLE-OL-MAPPING-INFO:1
    X-APPLE-OL-NOTE;TYPE=text/rtf;X-COMPRESSION=X-OL;X-HASH=03c582c83054be62e05
    e09df57aff23b;X-HASHALGORITHM=X-zMD5;ENCODING=B:fAAAAI0AAABMWkZ1YU/S1F8AAwF
    AAHIB9wK3VgSQZC0AcGECgAqScASQdzEYMTA0AUAPc2g5OIYwAUAAwHJnbDEMAd0Q4nIRMgsDDN
    A1DAEM0F0P4DYC0QoRAUBpAUB1VGxuAiBlAgBjAUBjAQu1IChBYnJhaGBhbXNlKQ9AFcA=
    END:VCARD

I tried decoding the b64 string and running it through LZF with python-lzf module:

    #!pip install python-lzf
    import base64
    import lzf
    
    base64_string = "fAAAAI0AAABMWkZ1YU/S1F8AAwFAAHIB9wK3VgSQZC0AcGECgAqScASQdzEYMTA0AUAPc2g5OIYwAUAAwHJnbDEMAd0Q4nIRMgsDDNA1DAEM0F0P4DYC0QoRAUBpAUB1VGxuAiBlAgBjAUBjAQu1IChBYnJhaGBhbXNlKQ9AFcA="
    
    # Decode the base64 string
    decoded_data = base64.b64decode(base64_string)
    
    # Decompress the LZF data using the lzf module and give a buffer of 1000
    decompressed_data = lzf.decompress(decoded_data, 1000)

But I get the error: ValueError: error in compressed data

Do you have an idea of how to decompress the data properly?

0

There are 0 answers