Update plist to 3.3.0.

This commit is contained in:
Markus Reiter 2017-04-28 20:51:07 +02:00
parent 539881f51a
commit 989a19b676
5 changed files with 44 additions and 21 deletions

View File

@ -1,7 +1,7 @@
Vendored Dependencies Vendored Dependencies
===================== =====================
* [plist](https://github.com/bleything/plist), version 3.1.0 * [plist](https://github.com/patsplat/plist), version 3.3.0
* [ruby-macho](https://github.com/Homebrew/ruby-macho), version 1.1.0 * [ruby-macho](https://github.com/Homebrew/ruby-macho), version 1.1.0

View File

@ -1,5 +1,5 @@
#!/usr/bin/env ruby # encoding: utf-8
#
# = plist # = plist
# #
# This is the main file for plist. Everything interesting happens in # This is the main file for plist. Everything interesting happens in
@ -15,7 +15,7 @@ require 'stringio'
require_relative 'plist/generator' require_relative 'plist/generator'
require_relative 'plist/parser' require_relative 'plist/parser'
require_relative 'plist/version'
module Plist module Plist
VERSION = '3.1.0'
end end

10
Library/Homebrew/vendor/plist/plist/generator.rb vendored Normal file → Executable file
View File

@ -1,12 +1,12 @@
#!/usr/bin/env ruby # encoding: utf-8
#
# = plist # = plist
# #
# Copyright 2006-2010 Ben Bleything and Patrick May # Copyright 2006-2010 Ben Bleything and Patrick May
# Distributed under the MIT License # Distributed under the MIT License
# #
module Plist ; end module Plist; end
# === Create a plist # === Create a plist
# You can dump an object to a plist in one of two ways: # You can dump an object to a plist in one of two ways:
@ -94,7 +94,7 @@ module Plist::Emit
output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ')) output << tag('date', element.utc.strftime('%Y-%m-%dT%H:%M:%SZ'))
when Date # also catches DateTime when Date # also catches DateTime
output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ')) output << tag('date', element.strftime('%Y-%m-%dT%H:%M:%SZ'))
when String, Symbol, Fixnum, Bignum, Integer, Float when String, Symbol, Integer, Float
output << tag(element_type(element), CGI::escapeHTML(element.to_s)) output << tag(element_type(element), CGI::escapeHTML(element.to_s))
when IO, StringIO when IO, StringIO
element.rewind element.rewind
@ -159,7 +159,7 @@ module Plist::Emit
when String, Symbol when String, Symbol
'string' 'string'
when Fixnum, Bignum, Integer when Integer
'integer' 'integer'
when Float when Float

View File

@ -1,5 +1,5 @@
#!/usr/bin/env ruby # encoding: utf-8
#
# = plist # = plist
# #
# Copyright 2006-2010 Ben Bleything and Patrick May # Copyright 2006-2010 Ben Bleything and Patrick May
@ -69,19 +69,14 @@ module Plist
@xml = plist_data_or_file @xml = plist_data_or_file
end end
# TODO: Update vendored `plist` parser when
# https://github.com/patsplat/plist/pull/38
# is merged.
@xml.force_encoding("UTF-8")
@listener = listener @listener = listener
end end
TEXT = /([^<]+)/ TEXT = /([^<]+)/
XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/um XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/m
DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/um DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/m
COMMENT_START = /\A<!--/u COMMENT_START = /\A<!--/
COMMENT_END = /.*?-->/um COMMENT_END = /.*?-->/m
def parse def parse
@ -96,7 +91,14 @@ module Plist
if @scanner.scan(COMMENT_START) if @scanner.scan(COMMENT_START)
@scanner.scan(COMMENT_END) @scanner.scan(COMMENT_END)
elsif @scanner.scan(XMLDECL_PATTERN) elsif @scanner.scan(XMLDECL_PATTERN)
encoding = parse_encoding_from_xml_declaration(@scanner[1])
next if encoding.nil?
# use the specified encoding for the rest of the file
next unless String.method_defined?(:force_encoding)
@scanner.string = @scanner.rest.force_encoding(encoding)
elsif @scanner.scan(DOCTYPE_PATTERN) elsif @scanner.scan(DOCTYPE_PATTERN)
next
elsif @scanner.scan(start_tag) elsif @scanner.scan(start_tag)
@listener.tag_start(@scanner[1], nil) @listener.tag_start(@scanner[1], nil)
if (@scanner[2] =~ /\/$/) if (@scanner[2] =~ /\/$/)
@ -111,6 +113,22 @@ module Plist
end end
end end
end end
private
def parse_encoding_from_xml_declaration(xml_declaration)
return unless defined?(Encoding)
xml_encoding = xml_declaration.match(/(?:\A|\s)encoding=(?:"(.*?)"|'(.*?)')(?:\s|\Z)/)
return if xml_encoding.nil?
begin
Encoding.find(xml_encoding[1])
rescue ArgumentError
nil
end
end
end end
class PTag class PTag
@ -218,7 +236,7 @@ module Plist
data = Base64.decode64(text.gsub(/\s+/, '')) unless text.nil? data = Base64.decode64(text.gsub(/\s+/, '')) unless text.nil?
begin begin
return Marshal.load(data) return Marshal.load(data)
rescue Exception => e rescue Exception
io = StringIO.new io = StringIO.new
io.write data io.write data
io.rewind io.rewind

View File

@ -0,0 +1,5 @@
# encoding: utf-8
module Plist
VERSION = '3.3.0'.freeze
end