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

Support Binary Plists #28

Open
patsplat opened this issue Jan 28, 2016 · 7 comments
Open

Support Binary Plists #28

patsplat opened this issue Jan 28, 2016 · 7 comments

Comments

@patsplat
Copy link
Owner

I have a problem with Plist::parse_xml when parse binary plist
(plist: https://www.dropbox.com/s/so8h9nk0x3pemwq/Info.plist?dl=0)

/Library/Ruby/Gems/2.0.0/gems/plist-3.1.0/lib/plist/parser.rb:91:in `scan': invalid byte sequence in UTF-8 (ArgumentError)

#21 (comment)

@microspino
Copy link

microspino commented Jul 13, 2016

Same problem here trying to parse ~/Library/Safari/Bookmarks.plist with plist-3.2.0 using
ruby 2.0.0p598 on Mac OS X 10.11.5

@vesan
Copy link

vesan commented Jul 31, 2017

The Safari bookmarks file can be converted to XML (which plist gem can process) with:

plutil -convert xml1 -o Bookmarks.xml ~/Library/Safari/Bookmarks.plist

@patsplat
Copy link
Owner Author

This issue is a placeholder for integrating backends from other ruby plist libraries

https://github.com/ckruse/CFPropertyList

@patsplat
Copy link
Owner Author

@vesan thanks for the pointer to the OSX plutil utility

@Nakilon
Copy link

Nakilon commented Apr 26, 2019

Was trying to pass the plist file content instead of filename to solve the issue but had the File.exist? ArgumentError because of some null bytes, so the

File.exist? plist_data_or_file.encode("UTF-8", invalid: :replace, undef: :replace).delete(?\x0)

fixed that for me and I was going to make a pull request but found this issue and now I guess that won't help anyway...

@patsplat
Copy link
Owner Author

@Nakilon are you working with a binary plist, or are you having a different issue?

@Nakilon
Copy link

Nakilon commented Apr 29, 2019

@patsplat yes, the file I need to parse appears to be binary.

To solve this I've used https://github.com/ckruse/CFPropertyList but that probably results in more code because of these .value, I'm not sure:

    displays = CFPropertyList::List.new(file: "/Library/Preferences/com.apple.windowserver.plist").
      value.value["DisplayAnyUserSets"].value.flat_map(&:value).map{ |i| i.value.values_at("OriginX", "OriginY", "Width", "Height").map(&:value) }

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

5 participants