aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Reiter2017-04-29 02:55:58 +0200
committerGitHub2017-04-29 02:55:58 +0200
commitb067700fd7a06f4f4a7eac006d5dae990c466a90 (patch)
tree001b44dbe5bb8b711d20e5343f5565e9838c358e
parent539881f51a69b1f5cf169766d1115c8b7343bd09 (diff)
parent989a19b676a73a0c580eafe72b9fced0ee32278b (diff)
downloadbrew-b067700fd7a06f4f4a7eac006d5dae990c466a90.tar.bz2
Merge pull request #2563 from reitermarkus/plist
Update `plist` to 3.3.0.
-rw-r--r--Library/Homebrew/vendor/README.md2
-rwxr-xr-xLibrary/Homebrew/vendor/plist/plist.rb6
-rwxr-xr-x[-rw-r--r--]Library/Homebrew/vendor/plist/plist/generator.rb10
-rwxr-xr-xLibrary/Homebrew/vendor/plist/plist/parser.rb42
-rwxr-xr-xLibrary/Homebrew/vendor/plist/plist/version.rb5
5 files changed, 44 insertions, 21 deletions
diff --git a/Library/Homebrew/vendor/README.md b/Library/Homebrew/vendor/README.md
index 906d42918..b408631c7 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 0b828afc6..82ecb27d2 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
index 3b84c301f..84bef3aaf 100644..100755
--- 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 7d8bfab07..4de13f881 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*<!DOCTYPE\s+(.*?)(\[|>)/um
- COMMENT_START = /\A<!--/u
- COMMENT_END = /.*?-->/um
+ XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>*/m
+ DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/m
+ COMMENT_START = /\A<!--/
+ COMMENT_END = /.*?-->/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 000000000..80b1f73dd
--- /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