aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exception.hpp5
-rw-r--r--src/messaging/maildirFolder.cpp3
-rw-r--r--src/utility/file.hpp22
3 files changed, 26 insertions, 4 deletions
diff --git a/src/exception.hpp b/src/exception.hpp
index 41e113ac..78a595b5 100644
--- a/src/exception.hpp
+++ b/src/exception.hpp
@@ -534,7 +534,10 @@ class invalid_folder_name : public messaging_exception
{
public:
- invalid_folder_name(const string& error) : messaging_exception("Invalid folder name: " + error + ".") {}
+ invalid_folder_name(const string& error = "")
+ : messaging_exception(error.empty()
+ ? "Invalid folder name: " + error + "."
+ : "Invalid folder name.") {}
~invalid_folder_name() throw() {}
};
diff --git a/src/messaging/maildirFolder.cpp b/src/messaging/maildirFolder.cpp
index 854e7dfb..bfb6e5b1 100644
--- a/src/messaging/maildirFolder.cpp
+++ b/src/messaging/maildirFolder.cpp
@@ -198,6 +198,9 @@ void maildirFolder::create(const int type)
{
utility::fileSystemFactory* fsf = platformDependant::getHandler()->getFileSystemFactory();
+ if (!fsf->isValidPath(maildirUtils::getFolderFSPath(m_store, m_path, maildirUtils::FOLDER_PATH_ROOT)))
+ throw exceptions::invalid_folder_name();
+
utility::auto_ptr <utility::file> rootDir = fsf->create
(maildirUtils::getFolderFSPath(m_store, m_path, maildirUtils::FOLDER_PATH_ROOT));
diff --git a/src/utility/file.hpp b/src/utility/file.hpp
index 1f92696b..5dc7d01d 100644
--- a/src/utility/file.hpp
+++ b/src/utility/file.hpp
@@ -204,21 +204,37 @@ public:
* @param path full path (absolute) of the file
* @return new file object for the path
*/
- virtual file* create(const file::path& path) = 0;
+ virtual file* create(const file::path& path) const = 0;
/** Parse a path contained in a string.
*
* @param str string containing a path in a system-dependant representation
* @return path object (abstract representation)
*/
- virtual file::path stringToPath(const string& str) = 0;
+ virtual const file::path stringToPath(const string& str) const = 0;
/** Return the system-dependant string representation for the specified path.
*
* @param path abstract representation of the path
* @return string representation of the path
*/
- virtual string pathToString(const file::path& path) = 0;
+ virtual const string pathToString(const file::path& path) const = 0;
+
+ /** Test whether the specified path component is syntactically
+ * valid (ie: does not contain any 'special' character).
+ *
+ * @param comp path component to test
+ * @return true if the component is valid, false otherwise
+ */
+ virtual const bool isValidPathComponent(const file::path::component& comp) const = 0;
+
+ /** Test whether the specified path is syntactically valid
+ * (ie: components do not contain any 'special' character).
+ *
+ * @param path path to test
+ * @return true if the path is valid, false otherwise
+ */
+ virtual const bool isValidPath(const file::path& path) const = 0;
};