mirror of
https://github.com/Yetangitu/owncloud-apps.git
synced 2025-10-02 14:49:17 +02:00
Fixed: Root of user's Cloud can be as root directory for OPDS
This commit is contained in:
parent
2a62589537
commit
8cec157c7b
2 changed files with 25 additions and 17 deletions
|
@ -23,27 +23,27 @@ $fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : '';
|
|||
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
|
||||
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName());
|
||||
|
||||
if (!is_null($rootPath)){
|
||||
if (\OC\Files\Filesystem::file_exists($rootPath) === false ){
|
||||
\OCP\JSON::error(
|
||||
array(
|
||||
'data' => array('message'=> $l->t('Directory does not exist!'))
|
||||
)
|
||||
);
|
||||
} else {
|
||||
Config::set('root_path', $rootPath);
|
||||
\OCP\JSON::success(
|
||||
array(
|
||||
'data' => array('message'=> $l->t('Settings updated successfully.'))
|
||||
)
|
||||
);
|
||||
}
|
||||
if (!strlen($rootPath) ||
|
||||
\OC\Files\Filesystem::isValidPath($rootPath) === false ||
|
||||
\OC\Files\Filesystem::file_exists($rootPath) === false ) {
|
||||
\OCP\JSON::error(
|
||||
array(
|
||||
'data' => array('message'=> $l->t('Directory does not exist!'))
|
||||
)
|
||||
);
|
||||
} else {
|
||||
Config::set('root_path', $rootPath);
|
||||
Config::set('enable', $opdsEnable);
|
||||
Config::set('file_types', $fileTypes);
|
||||
Config::set('skip_list', $skipList);
|
||||
Config::set('feed_title', $feedTitle);
|
||||
Config::set('id', Util::genUuid());
|
||||
exit();
|
||||
|
||||
\OCP\JSON::success(
|
||||
array(
|
||||
'data' => array('message'=> $l->t('Settings updated successfully.'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
exit();
|
||||
|
|
|
@ -69,6 +69,14 @@ class Files extends \OCA\Files\Helper
|
|||
* @return bool true if $child is a subdirectory of $parent
|
||||
*/
|
||||
public static function isChild($parent, $child) {
|
||||
return strpos($child, $parent . '/') === 0;
|
||||
|
||||
if ($parent[0] !== '/') {
|
||||
$parent = '/' . $parent;
|
||||
}
|
||||
if (strlen($parent) > 1 && substr($parent, -1) !== '/') {
|
||||
$parent .= '/';
|
||||
}
|
||||
|
||||
return (strpos($child, $parent) === 0 && strcmp($child, $parent) !== 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue