Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Fix to bugreport #905 and #893
Browse files Browse the repository at this point in the history
Regarding #905:

When returning an Ajax result, inside a json string value don't use addslashes.
You don't want both " and ' escaped at the same time. Instead just use
str_replace('"','\"',$Str).

Regarding #893:

A misplaced dir and file separator ',' lead to malformed json which could result in
a non loadable subtree.

Fixes #893: webui cannot list dirs with only files in them
Fixes #905: Restore WebUI - Enable to browse directory when a file name contain a single quote
  • Loading branch information
fbergkemper committed Feb 13, 2018
1 parent 85483ba commit ee232a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions module/Restore/src/Restore/Controller/RestoreController.php
Expand Up @@ -346,7 +346,7 @@ private function buildSubtree()
--$dnum;
$items .= '{';
$items .= '"id":"-' . $dir['pathid'] . '"';
$items .= ',"text":"' . preg_replace('/[\x00-\x1F\x7F]/', '', $dir["name"]) . '"';
$items .= ',"text":"' . preg_replace('/[\x00-\x1F\x7F]/', '', str_replace('"', '\"', $dir["name"])) . '"';
$items .= ',"icon":"glyphicon glyphicon-folder-close"';
$items .= ',"state":""';
$items .= ',"data":' . \Zend\Json\Json::encode($dir, \Zend\Json\Json::TYPE_OBJECT);
Expand All @@ -358,18 +358,18 @@ private function buildSubtree()
}
}

}
if($fnum > 0) {
$items .= ",";
}

if( $tmp > 2 && $fnum > 0 ) {
$items .= ",";
}

if($fnum > 0) {

foreach($this->files as $file) {
$items .= '{';
$items .= '"id":"' . $file["fileid"] . '"';
$items .= ',"text":"' . preg_replace('/[\x00-\x1F\x7F]/', '', addslashes($file["name"])) . '"';
$items .= ',"text":"' . preg_replace('/[\x00-\x1F\x7F]/', '', str_replace('"', '\"', $file["name"])) . '"';
$items .= ',"icon":"glyphicon glyphicon-file"';
$items .= ',"state":""';
$items .= ',"data":' . \Zend\Json\Json::encode($file, \Zend\Json\Json::TYPE_OBJECT);
Expand Down

1 comment on commit ee232a6

@Udhayakumar2201
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi...
After modify this file same as Bareos webui Restore tab take too much time for particular client backup.
for your information that back up file size only 500 MB.
Please advice me to fix this issue.

Thanks in Advance.
Udhayakumar R

Please sign in to comment.