You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem? 1. Right click on a directory in file manager tab and select create new .torrent What is the expected output? What do you see instead? files in directory are listed as
// What environment are you using? 1. ruTorrent version is 3.6 svn 2404
2. rTorrent version is... 0.9.3/0.13.3
3. lighttpd 1.4.29 on debian
4. chromium Are some errors present in the web-server log? No Are some errors present in the browser error console? No Please provide any additional information below. The extra '/' ends up creating a zero length string in the torrent file. Some sites are not able to handle the zero length string and interpret it as a file.
The problem is in Torrent.php in the 'folder' function. The function sets $this->basedir and then strips any trailing '/' off. But it then calls the 'files' function with $dir which still has the trailing slash in place. Within the 'files' function, a '/' is added between the base path and each file name. This results in the double '/'.
The fix is pretty simple. Pass $this->basedir into the files function instead of $dir since $this->basedir has had any trailing slashes removed.
Here is the fix:
private function folder( $dir, $piece_length )
{
$this->basedir = $dir;
$len = strlen($this->basedir);
if(($len>1) && ($this->basedir[$len-1]=='/'))
$this->basedir = substr($this->basedir,0,-1);
return($this->files( self::scandir( $this->basedir ), $piece_length));
}
The problem above ends up creating a list with the first element being a zero length string. Since there should never be a valid reason to have a zero length string in the bencoded data, we can avoid it (and any other place where a zero length string might get created) by checking the length of the string at encoding time and return an empty string instead of a "0:" string.
From beastly...@gmail.com on March 29, 2014 20:24:20
What steps will reproduce the problem? 1. Right click on a directory in file manager tab and select create new .torrent What is the expected output? What do you see instead? files in directory are listed as
// What environment are you using? 1. ruTorrent version is 3.6 svn 24042. rTorrent version is... 0.9.3/0.13.3
3. lighttpd 1.4.29 on debian
4. chromium Are some errors present in the web-server log? No Are some errors present in the browser error console? No Please provide any additional information below. The extra '/' ends up creating a zero length string in the torrent file. Some sites are not able to handle the zero length string and interpret it as a file.
The problem is in Torrent.php in the 'folder' function. The function sets $this->basedir and then strips any trailing '/' off. But it then calls the 'files' function with $dir which still has the trailing slash in place. Within the 'files' function, a '/' is added between the base path and each file name. This results in the double '/'.
The fix is pretty simple. Pass $this->basedir into the files function instead of $dir since $this->basedir has had any trailing slashes removed.
Here is the fix:
private function folder( $dir, $piece_length )
{
$this->basedir = $dir;
$len = strlen($this->basedir);
if(($len>1) && ($this->basedir[$len-1]=='/'))
$this->basedir = substr($this->basedir,0,-1);
return($this->files( self::scandir( $this->basedir ), $piece_length));
}
The problem above ends up creating a list with the first element being a zero length string. Since there should never be a valid reason to have a zero length string in the bencoded data, we can avoid it (and any other place where a zero length string might get created) by checking the length of the string at encoding time and return an empty string instead of a "0:" string.
Fix:
static private function encode_string( $string )
{
if( strlen( $string ))
return(strlen( $string ) . ':' . $string);
else
return "";
}
Original issue: http://code.google.com/p/rutorrent/issues/detail?id=900
The text was updated successfully, but these errors were encountered: