Sun Nov 6 07:44:28 2011 UTC ()
Apply some changes taken from upstream for net/mikutter version 0.0.4.
Bump PKGREVISION.
(obache)
diff -r1.4 -r1.5 pkgsrc/net/ruby-addressable/Makefile
diff -r1.4 -r1.5 pkgsrc/net/ruby-addressable/distinfo
diff -r0 -r1.1 pkgsrc/net/ruby-addressable/patches/patch-lib_addressable_template.rb
diff -r0 -r1.1 pkgsrc/net/ruby-addressable/patches/patch-lib_addressable_uri.rb
--- pkgsrc/net/ruby-addressable/Makefile 2011/06/19 02:50:20 1.4
+++ pkgsrc/net/ruby-addressable/Makefile 2011/11/06 07:44:27 1.5
| @@ -1,12 +1,13 @@ | | | @@ -1,12 +1,13 @@ |
1 | # $NetBSD: Makefile,v 1.4 2011/06/19 02:50:20 taca Exp $ | | 1 | # $NetBSD: Makefile,v 1.5 2011/11/06 07:44:27 obache Exp $ |
2 | | | 2 | |
3 | DISTNAME= addressable-2.2.6 | | 3 | DISTNAME= addressable-2.2.6 |
| | | 4 | PKGREVISION= 1 |
4 | CATEGORIES= net | | 5 | CATEGORIES= net |
5 | | | 6 | |
6 | MAINTAINER= pkgsrc-users@NetBSD.org | | 7 | MAINTAINER= pkgsrc-users@NetBSD.org |
7 | HOMEPAGE= http://addressable.rubyforge.org/ | | 8 | HOMEPAGE= http://addressable.rubyforge.org/ |
8 | COMMENT= Replacement for the URI Implementation of standard librrary | | 9 | COMMENT= Replacement for the URI Implementation of standard librrary |
9 | LICENSE= mit | | 10 | LICENSE= mit |
10 | | | 11 | |
11 | .include "../../lang/ruby/gem.mk" | | 12 | .include "../../lang/ruby/gem.mk" |
12 | .include "../../mk/bsd.pkg.mk" | | 13 | .include "../../mk/bsd.pkg.mk" |
--- pkgsrc/net/ruby-addressable/distinfo 2011/06/19 02:50:20 1.4
+++ pkgsrc/net/ruby-addressable/distinfo 2011/11/06 07:44:27 1.5
| @@ -1,5 +1,7 @@ | | | @@ -1,5 +1,7 @@ |
1 | $NetBSD: distinfo,v 1.4 2011/06/19 02:50:20 taca Exp $ | | 1 | $NetBSD: distinfo,v 1.5 2011/11/06 07:44:27 obache Exp $ |
2 | | | 2 | |
3 | SHA1 (addressable-2.2.6.gem) = 0b46d26336521fdc1843a5efc515b8102ef8a60c | | 3 | SHA1 (addressable-2.2.6.gem) = 0b46d26336521fdc1843a5efc515b8102ef8a60c |
4 | RMD160 (addressable-2.2.6.gem) = 52df9776570df16e4014f3add8799269ed506c0c | | 4 | RMD160 (addressable-2.2.6.gem) = 52df9776570df16e4014f3add8799269ed506c0c |
5 | Size (addressable-2.2.6.gem) = 97792 bytes | | 5 | Size (addressable-2.2.6.gem) = 97792 bytes |
| | | 6 | SHA1 (patch-lib_addressable_template.rb) = e6f9b63e4fca8007246924d98efbc72c34a8267a |
| | | 7 | SHA1 (patch-lib_addressable_uri.rb) = 41f7bc99d7bf18a62bf4b181a0ee094de57a1c5c |
$NetBSD: patch-lib_addressable_template.rb,v 1.1 2011/11/06 07:44:28 obache Exp $
* Fixed variable shadowing (from upstream repo).
--- lib/addressable/template.rb.orig 2011-11-06 07:18:52.000000000 +0000
+++ lib/addressable/template.rb
@@ -931,7 +931,7 @@ module Addressable
values.pop if values[-1] == ""
if processor && processor.respond_to?(:restore)
- values.map! { |value| processor.restore(variables.first, value) }
+ values.map! { |val| processor.restore(variables.first, val) }
end
values = values.first if values.size == 1
if mapping[variables.first] == nil || mapping[variables.first] == values
@@ -965,7 +965,7 @@ module Addressable
values = value.split(argument, -1)
values.pop if values[-1] == ""
if processor && processor.respond_to?(:restore)
- values.map! { |value| processor.restore(variables.first, value) }
+ values.map! { |val| processor.restore(variables.first, val) }
end
values = values.first if values.size == 1
if mapping[variables.first] == nil || mapping[variables.first] == values
@@ -1034,7 +1034,7 @@ module Addressable
values = value.split(argument, -1)
values.pop if values[-1] == ""
if processor && processor.respond_to?(:restore)
- values.map! { |value| processor.restore(variables.first, value) }
+ values.map! { |val| processor.restore(variables.first, val) }
end
if mapping[variables.first] == nil || mapping[variables.first] == values
mapping[variables.first] = values
$NetBSD: patch-lib_addressable_uri.rb,v 1.1 2011/11/06 07:44:28 obache Exp $
* some fixes and improvements (from upstream repo).
--- lib/addressable/uri.rb.orig 2011-11-06 07:18:52.000000000 +0000
+++ lib/addressable/uri.rb
@@ -325,7 +325,11 @@ module Addressable
return nil if component.nil?
begin
- component = component.to_str
+ if component.kind_of?(Symbol) || component.kind_of?(Numeric)
+ component = component.to_s
+ else
+ component = component.to_str
+ end
rescue TypeError, NoMethodError
raise TypeError, "Can't convert #{component.class} into String."
end if !component.is_a? String
@@ -715,6 +719,7 @@ module Addressable
self.authority = options[:authority] if options[:authority]
self.path = options[:path] if options[:path]
self.query = options[:query] if options[:query]
+ self.query_values = options[:query_values] if options[:query_values]
self.fragment = options[:fragment] if options[:fragment]
end
end
@@ -1497,39 +1502,55 @@ module Addressable
# Only to be used for non-Array inputs. Arrays should preserve order.
new_query_values.sort!
end
- # new_query_values have form [['key1', 'value1'], ['key2', 'value2']]
- # Algorithm shamelessly stolen from Julien Genestoux, slightly modified
- buffer = ""
- stack = []
- e = lambda do |component|
- component = component.to_s if component.kind_of?(Symbol)
- URI.encode_component(component, CharacterClasses::UNRESERVED)
- end
- new_query_values.each do |key, value|
- if value.kind_of?(Hash)
- stack << [key, value]
- elsif value.kind_of?(Array)
- stack << [
- key,
- value.inject({}) { |accu, x| accu[accu.size.to_s] = x; accu }
- ]
+ ##
+ # Joins and converts parent and value into a properly encoded and
+ # ordered URL query.
+ #
+ # @private
+ # @param [String] parent an URI encoded component.
+ # @param [Array, Hash, Symbol, #to_str] value
+ #
+ # @return [String] a properly escaped and ordered URL query.
+ to_query = lambda do |parent, value|
+ if value.is_a?(Hash)
+ value = value.map do |key, val|
+ [
+ URI.encode_component(key, CharacterClasses::UNRESERVED),
+ val
+ ]
+ end
+ value.sort!
+ buffer = ""
+ value.each do |key, val|
+ new_parent = "#{parent}[#{key}]"
+ buffer << "#{to_query.call(new_parent, val)}&"
+ end
+ return buffer.chop
+ elsif value.is_a?(Array)
+ buffer = ""
+ value.each_with_index do |val, i|
+ new_parent = "#{parent}[#{i}]"
+ buffer << "#{to_query.call(new_parent, val)}&"
+ end
+ return buffer.chop
elsif value == true
- buffer << "#{e.call(key)}&"
+ return parent
else
- buffer << "#{e.call(key)}=#{e.call(value)}&"
+ encoded_value = URI.encode_component(
+ value, CharacterClasses::UNRESERVED
+ )
+ return "#{parent}=#{encoded_value}"
end
end
- stack.each do |(parent, hash)|
- (hash.sort_by { |key| key.to_s }).each do |(key, value)|
- if value.kind_of?(Hash)
- stack << ["#{parent}[#{key}]", value]
- elsif value == true
- buffer << "#{parent}[#{e.call(key)}]&"
- else
- buffer << "#{parent}[#{e.call(key)}]=#{e.call(value)}&"
- end
- end
+
+ # new_query_values have form [['key1', 'value1'], ['key2', 'value2']]
+ buffer = ""
+ new_query_values.each do |parent, value|
+ encoded_parent = URI.encode_component(
+ parent, CharacterClasses::UNRESERVED
+ )
+ buffer << "#{to_query.call(encoded_parent, value)}&"
end
self.query = buffer.chop
end
@@ -2182,7 +2203,7 @@ module Addressable
parent = normalized_path.match(NPATH2)
if parent && ((parent[1] != PARENT1 && parent[1] != PARENT2) \
|| (parent[2] != PARENT1 && parent[2] != PARENT2))
- mod ||= normalized_path.gsub!(/\/#{parent[1]}\/\.\.\/|(\/#{parent[2]}\/\.\.$)/, SLASH)
+ mod ||= normalized_path.gsub!(/\/#{Regexp.escape(parent[1].to_s)}\/\.\.\/|(\/#{Regexp.escape(parent[2].to_s)}\/\.\.$)/, SLASH)
end
mod ||= normalized_path.gsub!(NPATH3, EMPTYSTR)