1
0
Fork 0
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:
Alexander Yamshanov 2016-07-04 04:56:02 +06:00
parent 2a62589537
commit 8cec157c7b
2 changed files with 25 additions and 17 deletions

View file

@ -23,8 +23,9 @@ $fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : '';
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg'; $skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName()); $feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName());
if (!is_null($rootPath)){ if (!strlen($rootPath) ||
if (\OC\Files\Filesystem::file_exists($rootPath) === false ){ \OC\Files\Filesystem::isValidPath($rootPath) === false ||
\OC\Files\Filesystem::file_exists($rootPath) === false ) {
\OCP\JSON::error( \OCP\JSON::error(
array( array(
'data' => array('message'=> $l->t('Directory does not exist!')) 'data' => array('message'=> $l->t('Directory does not exist!'))
@ -32,19 +33,18 @@ if (!is_null($rootPath)){
); );
} else { } else {
Config::set('root_path', $rootPath); 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());
\OCP\JSON::success( \OCP\JSON::success(
array( array(
'data' => array('message'=> $l->t('Settings updated successfully.')) 'data' => array('message'=> $l->t('Settings updated successfully.'))
) )
); );
} }
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();
}
exit(); exit();

View file

@ -69,6 +69,14 @@ class Files extends \OCA\Files\Helper
* @return bool true if $child is a subdirectory of $parent * @return bool true if $child is a subdirectory of $parent
*/ */
public static function isChild($parent, $child) { 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);
} }
} }