{"action":"closed","issue":{"url":"https://api.github.com/repos/SIB-FRANCE/Polyfony2/issues/58","labels_url":"https://api.github.com/repos/SIB-FRANCE/Polyfony2/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/SIB-FRANCE/Polyfony2/issues/58/comments","events_url":"https://api.github.com/repos/SIB-FRANCE/Polyfony2/issues/58/events","html_url":"https://github.com/SIB-FRANCE/Polyfony2/issues/58","id":57931226,"number":58,"title":"Filesystem::chroot()","user":{"login":"AnnoyingTechnology","id":5336824,"avatar_url":"https://avatars.githubusercontent.com/u/5336824?v=3","gravatar_id":"","url":"https://api.github.com/users/AnnoyingTechnology","html_url":"https://github.com/AnnoyingTechnology","followers_url":"https://api.github.com/users/AnnoyingTechnology/followers","following_url":"https://api.github.com/users/AnnoyingTechnology/following{/other_user}","gists_url":"https://api.github.com/users/AnnoyingTechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/AnnoyingTechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnnoyingTechnology/subscriptions","organizations_url":"https://api.github.com/users/AnnoyingTechnology/orgs","repos_url":"https://api.github.com/users/AnnoyingTechnology/repos","events_url":"https://api.github.com/users/AnnoyingTechnology/events{/privacy}","received_events_url":"https://api.github.com/users/AnnoyingTechnology/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/SIB-FRANCE/Polyfony2/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-17T14:36:46Z","updated_at":"2015-02-17T22:41:35Z","closed_at":"2015-02-17T22:41:35Z","body":"```php\r\n\t// this will restrict a path to the data storage folder\r\n\tpublic static function chroot($path='/', $override = false) {\r\n\r\n\t\t// if chrooting is enabled in the configuration\r\n\t\tif(Config::get('filesystem', 'chroot') && !$override) {\r\n\t\t\t// if the path already has the proper (ch)root\r\n\t\t\tif(strpos($path, Config::get('filesystem', 'data_path')) === 0) {\r\n\t\t\t\t// remove the root, remove double dots\r\n\t\t\t\t$path = str_replace(array(Config::get('filesystem', 'data_path'), '..'), '', $path);\r\n\t\t\t\t// re-add the root\r\n\t\t\t\treturn(Config::get('filesystem', 'data_path') . $path);\r\n\t\t\t}\r\n\t\t\t// the path doesn't start with the (ch)root\r\n\t\t\telse {\r\n\t\t\t\t// remove all double dots and add the root path\r\n\t\t\t\treturn(Config::get('filesystem', 'data_path') . str_replace('..','',$path));\r\n\t\t\t}\r\n\t\t}\r\n\t\t// return the path (altered or not)\r\n\t\treturn($path);\r\n\r\n\t}\r\n```\r\n\r\nhttps://github.com/SIB-FRANCE/Polyfony2/blob/master/Private/Vendor/Polyfony/Filesystem.php#L18"}}