Hello community,

here is the log from the commit of package rubygem-rspec-support for 
openSUSE:Factory checked in at 2015-03-01 14:57:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-rspec-support (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-rspec-support.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-rspec-support"

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/rubygem-rspec-support/rubygem-rspec-support.changes  
    2015-02-08 13:03:35.000000000 +0100
+++ 
/work/SRC/openSUSE:Factory/.rubygem-rspec-support.new/rubygem-rspec-support.changes
 2015-03-01 14:57:46.000000000 +0100
@@ -1,0 +2,9 @@
+Thu Feb 26 05:34:24 UTC 2015 - co...@suse.com
+
+- updated to version 3.2.2
+ Bug Fixes:
+ 
+ * Fix an encoding issue with `EncodedString#split` when encountering an
+   invalid byte string. (Benjamin Fleischer, #1760)
+
+-------------------------------------------------------------------

Old:
----
  rspec-support-3.2.1.gem

New:
----
  rspec-support-3.2.2.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-rspec-support.spec ++++++
--- /var/tmp/diff_new_pack.0Rltqm/_old  2015-03-01 14:57:47.000000000 +0100
+++ /var/tmp/diff_new_pack.0Rltqm/_new  2015-03-01 14:57:47.000000000 +0100
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-rspec-support
-Version:        3.2.1
+Version:        3.2.2
 Release:        0
 %define mod_name rspec-support
 %define mod_full_name %{mod_name}-%{version}

++++++ rspec-support-3.2.1.gem -> rspec-support-3.2.2.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Changelog.md new/Changelog.md
--- old/Changelog.md    2015-02-04 23:48:43.000000000 +0100
+++ new/Changelog.md    2015-02-24 04:35:55.000000000 +0100
@@ -1,3 +1,10 @@
+### 3.2.2 / 2015-02-23
+
+Bug Fixes:
+
+* Fix an encoding issue with `EncodedString#split` when encountering an
+  invalid byte string. (Benjamin Fleischer, #1760)
+
 ### 3.2.1 / 2015-02-04
 [Full Changelog](http://github.com/rspec/rspec-support/compare/v3.2.0...v3.2.1)
 
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
Files old/checksums.yaml.gz.sig and new/checksums.yaml.gz.sig differ
Files old/data.tar.gz.sig and new/data.tar.gz.sig differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rspec/support/encoded_string.rb 
new/lib/rspec/support/encoded_string.rb
--- old/lib/rspec/support/encoded_string.rb     2015-02-04 23:48:43.000000000 
+0100
+++ new/lib/rspec/support/encoded_string.rb     2015-02-24 04:35:55.000000000 
+0100
@@ -3,16 +3,32 @@
     # @private
     class EncodedString
       # Reduce allocations by storing constants.
-      UTF_8 = "UTF-8"
-      US_ASCII = 'US-ASCII'
-      #  else: '?' 63.chr ("\x3F")
+      UTF_8    = "UTF-8"
+      US_ASCII = "US-ASCII"
+      #
+      # In MRI 2.1 'invalid: :replace' changed to also replace an invalid byte 
sequence
+      # see https://github.com/ruby/ruby/blob/v2_1_0/NEWS#L176
+      # https://www.ruby-forum.com/topic/6861247
+      # https://twitter.com/nalsh/status/553413844685438976
+      #
+      # For example, given:
+      #   "\x80".force_encoding("Emacs-Mule").encode(:invalid => 
:replace).bytes.to_a
+      #
+      # On MRI 2.1 or above: 63  # '?'
+      # else               : 128 # "\x80"
+      #
+      # Ruby's default replacement string is:
+      #   U+FFFD ("\xEF\xBF\xBD"), for Unicode encoding forms, else
+      #   ?      ("\x3F")
       REPLACE = "?"
       ENCODE_UNCONVERTABLE_BYTES =  {
         :invalid => :replace,
-        :undef   => :replace
+        :undef   => :replace,
+        :replace => REPLACE
       }
       ENCODE_NO_CONVERTER = {
         :invalid => :replace,
+        :replace => REPLACE
       }
 
       def initialize(string, encoding=nil)
@@ -54,7 +70,7 @@
         #     vs "\x80".encode('UTF-8','ASCII-8BIT', undef: :replace, replace: 
'<undef>')
         #     # => '<undef>'
         #   Encoding::CompatibilityError
-        #    when Enconding.compatbile?(str1, str2) is false
+        #     when Encoding.compatibile?(str1, str2) is nil
         #     e.g. utf_16le_emoji_string.split("\n")
         #     e.g. valid_unicode_string.encode(utf8_encoding) << ascii_string
         #   Encoding::InvalidByteSequenceError:
@@ -64,13 +80,13 @@
         #     vs "\x80".encode('UTF-8','US-ASCII', invalid: :replace, replace: 
'<byte>')
         #     # => '<byte>'
         #   ArgumentError
-        #    when operating on a string with invalid bytes
-        #     e.g."\xEF".split("\n")
+        #     when operating on a string with invalid bytes
+        #     e.g."\x80".split("\n")
         #   TypeError
-        #    when a symbol is passed as an encoding
-        #    Encoding.find(:"utf-8")
-        #    when calling force_encoding on an object
-        #    that doesn't respond to #to_str
+        #     when a symbol is passed as an encoding
+        #     Encoding.find(:"UTF-8")
+        #     when calling force_encoding on an object
+        #     that doesn't respond to #to_str
         #
         # Raised by transcoding methods:
         #   Encoding::ConverterNotFoundError:
@@ -80,25 +96,35 @@
         #     e.g. "\x80".force_encoding('ASCII-8BIT').encode('Emacs-Mule')
         #
         # Raised by byte <-> char conversions
-        #  RangeError: out of char range
-        #   e.g. the UTF-16LE emoji: 128169.chr
+        #   RangeError: out of char range
+        #     e.g. the UTF-16LE emoji: 128169.chr
         def matching_encoding(string)
+          string = remove_invalid_bytes(string)
           string.encode(@encoding)
         rescue Encoding::UndefinedConversionError, 
Encoding::InvalidByteSequenceError
-          normalize_missing(string.encode(@encoding, 
ENCODE_UNCONVERTABLE_BYTES))
+          string.encode(@encoding, ENCODE_UNCONVERTABLE_BYTES)
         rescue Encoding::ConverterNotFoundError
-          
normalize_missing(string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER))
+          string.dup.force_encoding(@encoding).encode(ENCODE_NO_CONVERTER)
         end
 
-        # Ruby's default replacement string is:
-        # for Unicode encoding forms: U+FFFD ("\xEF\xBF\xBD")
-        MRI_UNICODE_UNKOWN_CHARACTER = "\xEF\xBF\xBD".force_encoding(UTF_8)
-
-        def normalize_missing(string)
-          if @encoding.to_s == UTF_8
-            string.gsub(MRI_UNICODE_UNKOWN_CHARACTER, REPLACE)
-          else
-            string
+        # Prevents raising ArgumentError
+        if String.method_defined?(:scrub)
+          # 
https://github.com/ruby/ruby/blob/eeb05e8c11/doc/NEWS-2.1.0#L120-L123
+          # https://github.com/ruby/ruby/blob/v2_1_0/string.c#L8242
+          # https://github.com/hsbt/string-scrub
+          # 
https://github.com/rubinius/rubinius/blob/v2.5.2/kernel/common/string.rb#L1913-L1972
+          def remove_invalid_bytes(string)
+            string.scrub(REPLACE)
+          end
+        else
+          # http://stackoverflow.com/a/8711118/879854
+          # Loop over chars in a string replacing chars
+          # with invalid encoding, which is a pretty good proxy
+          # for the invalid byte sequence that causes an ArgumentError
+          def remove_invalid_bytes(string)
+            string.chars.map do |char|
+              char.valid_encoding? ? char : REPLACE
+            end.join
           end
         end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/rspec/support/version.rb 
new/lib/rspec/support/version.rb
--- old/lib/rspec/support/version.rb    2015-02-04 23:48:43.000000000 +0100
+++ new/lib/rspec/support/version.rb    2015-02-24 04:35:55.000000000 +0100
@@ -1,7 +1,7 @@
 module RSpec
   module Support
     module Version
-      STRING = '3.2.1'
+      STRING = '3.2.2'
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2015-02-04 23:48:43.000000000 +0100
+++ new/metadata        2015-02-24 04:35:55.000000000 +0100
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: rspec-support
 version: !ruby/object:Gem::Version
-  version: 3.2.1
+  version: 3.2.2
 platform: ruby
 authors:
 - David Chelimsky
@@ -48,7 +48,7 @@
   ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
   F3MdtaDehhjC
   -----END CERTIFICATE-----
-date: 2015-02-04 00:00:00.000000000 Z
+date: 2015-02-24 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: bundler
@@ -134,5 +134,5 @@
 rubygems_version: 2.2.2
 signing_key: 
 specification_version: 4
-summary: rspec-support-3.2.1
+summary: rspec-support-3.2.2
 test_files: []
Files old/metadata.gz.sig and new/metadata.gz.sig differ

-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to