diff --git a/Library/Homebrew/vendor/README.md b/Library/Homebrew/vendor/README.md index 906d429189..b408631c7a 100644 --- a/Library/Homebrew/vendor/README.md +++ b/Library/Homebrew/vendor/README.md @@ -1,7 +1,7 @@ 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 diff --git a/Library/Homebrew/vendor/plist/plist.rb b/Library/Homebrew/vendor/plist/plist.rb index 0b828afc6a..82ecb27d28 100755 --- a/Library/Homebrew/vendor/plist/plist.rb +++ b/Library/Homebrew/vendor/plist/plist.rb @@ -1,5 +1,5 @@ -#!/usr/bin/env ruby -# +# encoding: utf-8 + # = plist # # This is the main file for plist. Everything interesting happens in @@ -15,7 +15,7 @@ require 'stringio' require_relative 'plist/generator' require_relative 'plist/parser' +require_relative 'plist/version' module Plist - VERSION = '3.1.0' end diff --git a/Library/Homebrew/vendor/plist/plist/generator.rb b/Library/Homebrew/vendor/plist/plist/generator.rb old mode 100644 new mode 100755 index 3b84c301f3..84bef3aaf6 --- a/Library/Homebrew/vendor/plist/plist/generator.rb +++ b/Library/Homebrew/vendor/plist/plist/generator.rb @@ -1,12 +1,12 @@ -#!/usr/bin/env ruby -# +# encoding: utf-8 + # = plist # # Copyright 2006-2010 Ben Bleything and Patrick May # Distributed under the MIT License # -module Plist ; end +module Plist; end # === Create a plist # 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')) when Date # also catches DateTime 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)) when IO, StringIO element.rewind @@ -159,7 +159,7 @@ module Plist::Emit when String, Symbol 'string' - when Fixnum, Bignum, Integer + when Integer 'integer' when Float diff --git a/Library/Homebrew/vendor/plist/plist/parser.rb b/Library/Homebrew/vendor/plist/plist/parser.rb index 7d8bfab07f..4de13f8814 100755 --- a/Library/Homebrew/vendor/plist/plist/parser.rb +++ b/Library/Homebrew/vendor/plist/plist/parser.rb @@ -1,5 +1,5 @@ -#!/usr/bin/env ruby -# +# encoding: utf-8 + # = plist # # Copyright 2006-2010 Ben Bleything and Patrick May @@ -69,19 +69,14 @@ module Plist @xml = plist_data_or_file end - # TODO: Update vendored `plist` parser when - # https://github.com/patsplat/plist/pull/38 - # is merged. - @xml.force_encoding("UTF-8") - @listener = listener end TEXT = /([^<]+)/ - XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/um - DOCTYPE_PATTERN = /\s*)/um - COMMENT_START = /\A/um + XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/m + DOCTYPE_PATTERN = /\s*)/m + COMMENT_START = /\A/m def parse @@ -96,7 +91,14 @@ module Plist if @scanner.scan(COMMENT_START) @scanner.scan(COMMENT_END) 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) + next elsif @scanner.scan(start_tag) @listener.tag_start(@scanner[1], nil) if (@scanner[2] =~ /\/$/) @@ -111,6 +113,22 @@ module Plist 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 class PTag @@ -218,7 +236,7 @@ module Plist data = Base64.decode64(text.gsub(/\s+/, '')) unless text.nil? begin return Marshal.load(data) - rescue Exception => e + rescue Exception io = StringIO.new io.write data io.rewind diff --git a/Library/Homebrew/vendor/plist/plist/version.rb b/Library/Homebrew/vendor/plist/plist/version.rb new file mode 100755 index 0000000000..80b1f73ddc --- /dev/null +++ b/Library/Homebrew/vendor/plist/plist/version.rb @@ -0,0 +1,5 @@ +# encoding: utf-8 + +module Plist + VERSION = '3.3.0'.freeze +end