You are not logged in.

#1 2013-10-16 00:32:31

pcolbeck
Member
Registered: 2011-10-17
Posts: 16

Ruby Ripper UTF-8 crash

Hi

Does Ruby Ripper work on Arch any more ? I have installed the latest version using pacman and it fails on ripping to FLAC with the following error:

/usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1659:in `gsub!': incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1659:in `allFilter'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1636:in `tagFilter'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1597:in `block in setMetadata'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1596:in `times'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1596:in `setMetadata'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1479:in `attemptDirCreation'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:1685:in `overwriteDir'
	from /usr/lib/ruby/vendor_ruby/2.0.0/rr_lib.rb:2661:in `overwriteDir'
	from /usr/bin/rrip_cli:428:in `dir_exists'
	from /usr/bin/rrip_cli:447:in `update'
	from /usr/bin/rrip_cli:414:in `prepareRip'
	from /usr/bin/rrip_cli:331:in `showFreedbOptions'
	from /usr/bin/rrip_cli:305:in `showFreedb'
	from /usr/bin/rrip_cli:265:in `handleFreedb'
	from /usr/bin/rrip_cli:244:in `get_cd_info'
	from /usr/bin/rrip_cli:47:in `initialize'
	from /usr/bin/rrip_cli:486:in `new'
	from /usr/bin/rrip_cli:486:in `<main>'

Looks like an issue with the data from CDDB. It does this with whatever CD I try including really common ones like Pet Sounds.

Last edited by pcolbeck (2013-10-16 02:01:25)

Offline

#2 2014-05-26 21:33:30

bwv549
Member
Registered: 2013-12-13
Posts: 14

Re: Ruby Ripper UTF-8 crash

I wrote my own patch based on a perusal of this discussion and some trial and error.  Just save to a file (<PATCHFILE>) and `sudo patch /usr/lib/ruby/vendor_ruby/2.1.0/rr_lib.rb <PATCHFILE>`

*** rr_lib.rb    2014-01-11 05:41:20.000000000 -0700
--- rr_lib.FIXED.rb    2014-05-26 17:34:43.695898215 -0600
***************
*** 1467,1472 ****
--- 1467,1473 ----
          end
          
          dirName = fileFilter(dirName, true)
+     dirName.force_encoding("UTF-8")
          return File.expand_path(File.join(@settings['basedir'], dirName))
      end
  
***************
*** 1652,1665 ****
          if var.respond_to?(:encoding)
              # prepare for byte substitutions
              enc = var.encoding
!             var.force_encoding("ASCII-8BIT")
          end
  
          # replace utf-8 single quotes with latin single quote 
!         var.gsub!(/\342\200\230|\342\200\231/, "'") 
          
          # replace utf-8 double quotes with latin double quote
!         var.gsub!(/\342\200\234|\342\200\235/, '"') 
  
          if var.respond_to?(:encoding)
              # restore the old encoding
--- 1653,1667 ----
          if var.respond_to?(:encoding)
              # prepare for byte substitutions
              enc = var.encoding
!             #var.force_encoding("ASCII-8BIT")
!       var.force_encoding(enc)
          end
  
          # replace utf-8 single quotes with latin single quote 
!         #var.gsub!(/\342\200\230|\342\200\231/, "'") 
          
          # replace utf-8 double quotes with latin double quote
!         #var.gsub!(/\342\200\234|\342\200\235/, '"') 
  
          if var.respond_to?(:encoding)
              # restore the old encoding
***************
*** 1696,1702 ****
      end
  
      # create Playlist for each codec
!     def createPlaylist(codec)
          playlist = File.new(File.join(@dir[codec], 
              "#{@artistFile} - #{@albumFile} (#{codec}).m3u"), 'w')
          
--- 1698,1706 ----
      end
  
      # create Playlist for each codec
!   def createPlaylist(codec)
!     @artistFile.force_encoding("UTF-8")
!     @albumFile.force_encoding("UTF-8")
          playlist = File.new(File.join(@dir[codec], 
              "#{@artistFile} - #{@albumFile} (#{codec}).m3u"), 'w')
          
***************
*** 1722,1728 ****
          if track == "image"
              return File.join(@dir[codec], @image[codec])        
          else
!             return File.join(@dir[codec], @file[codec][track])
          end    
      end
  
--- 1726,1732 ----
          if track == "image"
              return File.join(@dir[codec], @image[codec])        
          else
!             return File.join(@dir[codec].force_encoding("UTF-8"), @file[codec][track].force_encoding("UTF-8"))
          end    
      end
  
***************
*** 2397,2403 ****
  
          command = String.new
          command.force_encoding("UTF-8") if command.respond_to?("force_encoding")
!         command +="flac #{@settings['flacsettings']} -o \"#{filename}\" #{tags}\
  \"#{@out.getTempFile(track, 1)}\""
          command += " 2>&1" unless @settings['verbose']
  
--- 2401,2407 ----
  
          command = String.new
          command.force_encoding("UTF-8") if command.respond_to?("force_encoding")
!         command +="flac #{@settings['flacsettings'].force_encoding("UTF-8")} -o \"#{filename.force_encoding("UTF-8")}\" #{tags.force_encoding("UTF-8")}\
  \"#{@out.getTempFile(track, 1)}\""
          command += " 2>&1" unless @settings['verbose']

Last edited by bwv549 (2014-05-26 23:47:50)

Offline

#3 2014-05-28 10:33:59

sekret
Member
Registered: 2013-07-22
Posts: 284

Re: Ruby Ripper UTF-8 crash

If this patch really solves the issue, it should be included in the package! So would you mind filing a bugreport and uploading the patch to make it downloadable? That way everyone benefits, not just those who see this thread.

Offline

#4 2015-04-24 16:51:24

Senselessfull
Member
Registered: 2014-06-03
Posts: 8

Re: Ruby Ripper UTF-8 crash

The patch doesn't work anymore as of this day but renaming all files so they use ascii only chars works.
Version I tested on was 0.6.2

Offline

#5 2017-05-05 23:23:17

clook
Member
Registered: 2017-05-05
Posts: 1

Re: Ruby Ripper UTF-8 crash

Hi, got the same bug with 0.6.2 release. It seems to come from the single / double quote regexp which is detected as UTF-8 in ruby 2 (and target string for replacement is forced as 8bit before)
=> we have to force the pattern as 8bit:

--- rr_lib.rb.orig	2017-05-06 01:16:54.772606904 +0200
+++ rr_lib.rb	2017-05-06 01:16:20.035279911 +0200
@@ -1657,10 +1657,10 @@
 		end
 
 		# replace utf-8 single quotes with latin single quote 
-		var.gsub!(/\342\200\230|\342\200\231/, "'") 
+		var.gsub!(/\342\200\230|\342\200\231/n, "'") 
 		
 		# replace utf-8 double quotes with latin double quote
-		var.gsub!(/\342\200\234|\342\200\235/, '"') 
+		var.gsub!(/\342\200\234|\342\200\235/n, '"') 
 
 		if var.respond_to?(:encoding)
 			# restore the old encoding

Works great in my case.

Cheers!

Offline

#6 2017-05-06 12:33:42

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,836
Website

Re: Ruby Ripper UTF-8 crash

Glad it worked for you, and thanks for sharing. I'm going to take this opportunity to close this old topic now.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB