gwokae / phpsvnclient

Automatically exported from code.google.com/p/phpsvnclient
0 stars 0 forks source link

$t = explode("/",$value); command leads to error when $value is not a string #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
$t = explode("/",$value); 
This command leads to error when $value is not a string but $value is not 
guaranteed to be a string.

Please encapsulate this command by a
        if (is_string($value)) {

Thus:
        if (is_string($value)) {
            $t = explode("/",$value);

            // start from the end and move backwards until we find a 
non-blank entry
            $index = count($t) - 1;
            while ($t[$index] == ""){
                $index--;
            }

            // check the last non-empty element to see if it's 
numeric. If so, it's the revision number
            if (is_numeric($t[$index])) {
                $this->_repVersion = $t[$index];
                break;
            }
        }

Original issue reported on code.google.com by bichselm...@gmail.com on 9 Feb 2010 at 3:49

GoogleCodeExporter commented 9 years ago
I'm having the same problem, but the above isn't the right solution.

The parser finds a D:href block, and sets $enable to true. The if($enable) 
{...} block assumes $value is a string (which it is) and looks for a version. 
If it doesn't find one, it continues to loop, assuming each subsequent value is 
a string.

However, if the first D:href block doesn't find a version, $enable should be 
set to false until a subsequent D:href block is found.

In summary:

if (is_numeric($t[$index])) {
  ...
}
else {
  $enable = false;
}

Original comment by lawsonjeremy@gmail.com on 12 Jul 2010 at 5:41

Attachments:

GoogleCodeExporter commented 9 years ago
Applied patch from lawsonjeremy

Original comment by alan.gohe on 20 Mar 2011 at 6:52