2008-04-24 01:14:03 |
Arsecroft |
description |
Every torrent file I've tried to read gives me the same error, "BEncode::DecodeError: invalid string length."
I've tried the torrents in several torrent clients, but they all work.
After editing bdecode.rb and adding two lines to BEncode::parse
begin
scanner.pos += length
rescue RangeError
puts "scanner.pos = " + scanner.pos.to_s
puts "length = " + length.to_s
raise BEncode::DecodeError, "invalid string length"
end
I get the following output:
irb(main):001:0> require 'bdecode.rb'
=> true
irb(main):002:0> BEncode::load_file("ubuntu-7.10-desktop-amd64.iso.torrent")
scanner.pos = 223
length = 27880
BEncode::DecodeError: invalid string length
from ./bdecode.rb:62:in `parse'
from ./bdecode.rb:43:in `parse'
from ./bdecode.rb:15:in `load'
from ./bdecode.rb:22:in `load_file'
from (irb):2
irb(main):003:0> File.open("ubuntu-7.10-desktop-amd64.iso.torrent").stat.size
=> 28105
here's the download link to the torrent file (It's also attatched):
http://releases.ubuntu.com/7.10/ubuntu-7.10-desktop-amd64.iso.torrent
ruby -v:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
gem -v:
1.1.0
BEncode gem version: 0.5.0 |
EDIT: I think it may have something to do with the way the file's encoded?
I added "puts str.length" before the begin statement, and the number is wildly different from what is expected.
length = 27880
str.length = 2000
When I load up the file (File.open(filename).read) it seems there are escaped chars and I guess ruby unescapes them?
Also, when I use ruby to rewrite the file, it gets much much smaller. 2kb down from 28kb.
--
Every torrent file I've tried to read gives me the same error, "BEncode::DecodeError: invalid string length."
I've tried the torrents in several torrent clients, but they all work.
After editing bdecode.rb and adding two lines to BEncode::parse
begin
scanner.pos += length
rescue RangeError
puts "scanner.pos = " + scanner.pos.to_s
puts "length = " + length.to_s
raise BEncode::DecodeError, "invalid string length"
end
I get the following output:
irb(main):001:0> require 'bdecode.rb'
=> true
irb(main):002:0> BEncode::load_file("ubuntu-7.10-desktop-amd64.iso.torrent")
scanner.pos = 223
length = 27880
BEncode::DecodeError: invalid string length
from ./bdecode.rb:62:in `parse'
from ./bdecode.rb:43:in `parse'
from ./bdecode.rb:15:in `load'
from ./bdecode.rb:22:in `load_file'
from (irb):2
irb(main):003:0> File.open("ubuntu-7.10-desktop-amd64.iso.torrent").stat.size
=> 28105
here's the download link to the torrent file (It's also attatched):
http://releases.ubuntu.com/7.10/ubuntu-7.10-desktop-amd64.iso.torrent
ruby -v:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
gem -v:
1.1.0
BEncode gem version: 0.5.0 |
|