CheckPath: Better validation routine
This commit is contained in:
+4
-1
@@ -8,7 +8,10 @@
|
||||
#include "JFJochException.h"
|
||||
|
||||
inline void CheckPath(const std::string &s) {
|
||||
if (!s.empty() && s.front() == '/')
|
||||
// CheckPath looks validates that s can be a valid file name
|
||||
// (in practice with an added suffix, .e.g. _master.h5 or .tiff)
|
||||
// It avoids paths going outside of a given directory
|
||||
if (!s.empty() && (s.front() == '/' || s.back() != '/'))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Path cannot start with slash");
|
||||
if (s.size() >= 3 && s.substr(0,3) == "../")
|
||||
|
||||
Reference in New Issue
Block a user