Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed how decode and encode worked, defaults were set the wrong way…

… around causing some torrents with large index sets to generate an incorrect hash value.
  • Loading branch information...
commit 14372398900ce4b60e5be0a7ce0e07ab3ad9a6bf 1 parent 162805c
@torrage authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 inc/TEapi.inc.php
View
14 inc/TEapi.inc.php
@@ -25,7 +25,7 @@ public function load( &$data )
try
{
$this->torrent = new BEncode();
- $this->torrent->decode( $data, true );
+ $this->torrent->decode( $data );
}
catch( Exception $e )
{
@@ -304,7 +304,7 @@ public function setPrivate( $value )
// Bencode the torrent
public function bencode()
{
- return $this->torrent->encode();
+ return $this->torrent->encode( null );
}
// Return the torrent's hash
@@ -425,7 +425,7 @@ public function count()
return count( $this->__data );
}
- public function decode( $data, $usegmp = false, $strict = false )
+ public function decode( $data, $usegmp = true, $strict = false )
{
$stack = array();
$offset = 0;
@@ -627,7 +627,7 @@ public function decode( $data, $usegmp = false, $strict = false )
throw new Exception( "Unexpected end of bencoded data" );
}
- function encode( $var = null, $autonumbers = true )
+ function encode( $var = null, $autonumbers = false )
{
if( $var === null )
{
@@ -665,7 +665,7 @@ function encode( $var = null, $autonumbers = true )
$text = 'd';
foreach( $var as $key => $val )
{
- $text .= strlen( $key ) . ':' . $key . $this->encode( $val );
+ $text .= strlen( $key ) . ':' . $key . $this->encode( $val, $autonumbers );
}
return $text . 'e';
}
@@ -674,7 +674,7 @@ function encode( $var = null, $autonumbers = true )
$text = 'l';
foreach( $var as $val )
{
- $text .= $this->encode( $val );
+ $text .= $this->encode( $val, $autonumbers );
}
return $text . 'e';
}
@@ -701,4 +701,4 @@ function __construct( $code )
{
$this->code = $code;
}
- }
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.