From d867cca366d1a7aa106bec98db52a2b416b10c26 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 8 Jul 2012 19:21:37 +0200 Subject: Check that the animal is actually inside the farm This makes sure that the animal that is specified in the URL is actually a subdirectory inside the farm and not somewhere else in the system. This allows that the animals are organized in different subdirectories for more complicated farm setups. --- inc/farm.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'inc/farm.php') diff --git a/inc/farm.php b/inc/farm.php index 8434e3067..51b0c0f78 100644 --- a/inc/farm.php +++ b/inc/farm.php @@ -46,6 +46,9 @@ function conf_path($farm) { if(isset($_REQUEST['animal']) || ('cli' == php_sapi_name() && isset($_SERVER['animal']))) { $mode = isset($_REQUEST['animal']) ? 'htaccess' : 'cli'; $animal = $mode == 'htaccess' ? $_REQUEST['animal'] : $_SERVER['animal']; + // check that $animal specifies a subdirectory of $farm + if (strpos(fullpath($farm.'/'.$animal), fullpath($farm).'/') !== 0) + nice_die('Sorry! Invalid Wiki name!'); if(!is_dir($farm.'/'.$animal)) nice_die("Sorry! This Wiki doesn't exist!"); if(!defined('DOKU_FARM')) define('DOKU_FARM', $mode); -- cgit v1.2.3