Changeset 1833
- Timestamp:
- 12/07/2011 11:23:02 PM (18 months ago)
- Files:
-
- 1 modified
-
trunk/handlers/files.xml/files.xml.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/handlers/files.xml/files.xml.php
r1828 r1833 48 48 // invocation of files.xml must provide $_GET['file'] and $_GET['action']. 49 49 // todo: add an error message here: probably, T_("The parameters you supplied are incorrect, one of the two revisions may have been removed.") should be splitted. 50 $this->Redirect( '');50 $this->Redirect(); 51 51 } 52 52 53 $file = $this->GetSafeVar('file', 'get'); 54 if(preg_match("/^[\.\/\\\]/", $file)) 53 // Sanitize the filename to prevent path traversal attacks 54 $file = $this->GetSafeVar('file','get'); 55 $matches = ''; 56 preg_match("/^.*?([^\.\/\\\]+\.[A-Za-z0-9]{2,4})$/", $file, $matches); 57 if(isset($matches[1])) 58 $file = $matches[1]; 59 else 55 60 { 56 $this->Redirect($this->Href(), T_("Sorry, files of this type are not allowed.")); 61 $this->SetRedirectMessage(T_("Invalid filename")); 62 $this->Redirect(); 57 63 } 64 58 65 // do the action 59 66 $action = $this->GetSafeVar('action', 'get');