ebarnard / rust-plist

A rusty plist parser.
MIT License
71 stars 42 forks source link

Parsing fails on binary plist containing `uid` typed values #40

Closed Bibliofile closed 5 years ago

Bibliofile commented 5 years ago

I'll grant this plist is rather unusual, but it does appear to be valid, and passing it through plutil -convert xml1 out.plist doesn't error, I haven't tried the XML version as my source provides binary data.

plists.zip

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>$archiver</key>
    <string>NSKeyedArchiver</string>
    <key>$objects</key>
    <array>
        <string>$null</string>
        <dict>
            <key>$class</key>
            <dict>
                <key>CF$UID</key>
                <integer>4</integer>
            </dict>
            <key>NSRangeCount</key>
            <integer>42</integer>
            <key>NSRangeData</key>
            <dict>
                <key>CF$UID</key>
                <integer>2</integer>
            </dict>
        </dict>
        <dict>
            <key>$class</key>
            <dict>
                <key>CF$UID</key>
                <integer>3</integer>
            </dict>
            <key>NS.data</key>
            <data>
            AwIIAQwGFQEXARkBGwIfCCwBMAEzATUDPAJAAkcBTAFTAVYCWwFk
            Am8CeAJ8AY0BAZABAZsBAaABAqYBAt0BAbwCAYAIA4QIAYYIBZMI
            AZgIA5wIAZ8IAaYIAbAIAbwIAccIAYBAAQ==
            </data>
        </dict>
        <dict>
            <key>$classes</key>
            <array>
                <string>NSMutableData</string>
                <string>NSData</string>
                <string>NSObject</string>
            </array>
            <key>$classname</key>
            <string>NSMutableData</string>
        </dict>
        <dict>
            <key>$classes</key>
            <array>
                <string>NSMutableIndexSet</string>
                <string>NSIndexSet</string>
                <string>NSObject</string>
            </array>
            <key>$classname</key>
            <string>NSMutableIndexSet</string>
        </dict>
    </array>
    <key>$top</key>
    <dict>
        <key>foundItems</key>
        <dict>
            <key>CF$UID</key>
            <integer>1</integer>
        </dict>
    </dict>
    <key>$version</key>
    <integer>100000</integer>
</dict>
</plist>
ebarnard commented 5 years ago

The binary plist contains uid typed values which plutil seems to convert into an integer when converting the plist to xml.

These are used exclusively by NSKeyedArchiver and are currently not supported as they break feature parity between binary and xml plists. I have no issue with the library supporting uids though if someone (you) has a use case that requires them.

Bibliofile commented 5 years ago

Ahh, so that's what it is doing. That makes sense now, I knew something was different about this plist. Thanks!

Support for uid values would be very convenient (or at least an error that points out what is going wrong), unfortunately I'm not in control of the source that creates these plists, It would be much nicer to deal with a "normal" plist.

ebarnard commented 5 years ago

At some point when I get time I'll implement uids but in the mean time more informative errors are coming soon (https://github.com/ebarnard/rust-plist/tree/better-errors).

ebarnard commented 5 years ago

Do you want to see if #41 fixes your issues.

Bibliofile commented 5 years ago

I will give it a shot this weekend, thanks for the quick turnaround!

On Mon, Jul 22, 2019 at 4:37 AM Ed Barnard notifications@github.com wrote:

Do you want to see if #41 https://github.com/ebarnard/rust-plist/pull/41 fixes your issues.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ebarnard/rust-plist/issues/40?email_source=notifications&email_token=ABRJWJ2IIMAACMP7SXU4R6DQAWEUZA5CNFSM4IE76222YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2PQLWY#issuecomment-513738203, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRJWJ5RSPI7RCCV3BXTTV3QAWEUZANCNFSM4IE7622Q .

Bibliofile commented 5 years ago

I just switched to using the master branch, and after fixing the build errors caused by changes to the types in plist::Value I can confirm that everything appears to be working as intended. Thanks!