Changeset 663


Ignore:
Timestamp:
Feb 21, 2012, 12:52:52 PM (9 years ago)
Author:
zerodeux
Message:

Try to rename only the file part and not the whole folder/file part - see bug #9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bearfile/bearfile.php

    r618 r663  
    7373  }
    7474
    75   $target0 = trim("$folder/$name", '.');
    76 
    77   $target  = $target0;
    78   $try    = 0;
    79   $max    = $bfh['version_max'];
    80   while (file_exists($target)) {
     75  $name0 = $name;
     76  $try   = 0;
     77  $max   = $bfh['version_max'];
     78  while (file_exists($target = "$folder/$name")) {
    8179    if (++$try > $max) {
    82       $bfh['error'] = "Could not write file, maximum number of versions ($max) reached.";
     80      $_name = htmlspecialchars($name);
     81      $bfh['error'] = "Could not write file '$_name', maximum number of versions ($max) reached.";
    8382      return $bfh;
    8483    }
    85     $target = preg_replace('/(\..+)?$/', "-$try\$1", $target0 , 1);
     84    $name = preg_replace('/(\..+)?$/', "-$try\$1", $name0 , 1);
    8685  }
    8786
     
    109108  );
    110109
    111   $bfh['status'] = "Your file as been uploaded as <b>'$name'</b>.<br/>".
    112                    "An email has been sent to <b>$email</b> with the relevant links.";
     110  $_name  = htmlspecialchars($name);
     111  $_email = htmlspecialchars($email);
     112  $bfh['status'] = "Your file as been uploaded as <b>'$_name'</b>.<br/>".
     113                   "An email has been sent to <b>$_email</b> with the relevant links.";
    113114  return $bfh;
    114115}
Note: See TracChangeset for help on using the changeset viewer.