aboutsummaryrefslogtreecommitdiff
path: root/butl/path.txx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-06-14 16:24:51 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-06-18 15:05:38 +0300
commit14e9635241fca41a7ba153040368256612ccb16f (patch)
tree73c24c5ac047338cd7afffe97db29f3188b14445 /butl/path.txx
parentd326f16dd40013e8bea639ff95c2b249e7867e5e (diff)
Check path validity in path::init() on Windows
Diffstat (limited to 'butl/path.txx')
-rw-r--r--butl/path.txx13
1 files changed, 12 insertions, 1 deletions
diff --git a/butl/path.txx b/butl/path.txx
index 56e2cf1..383f7fe 100644
--- a/butl/path.txx
+++ b/butl/path.txx
@@ -246,10 +246,21 @@ namespace butl
bool basic_path<C, K>::
init (string_type& s, bool exact)
{
+ size_type n (s.size ());
+
+#ifdef _WIN32
+ // We do not support any special Windows path name notations like in C:abc,
+ // \\?\c:\abc, \\server\abc and \\?\UNC\server\abc (more about them at
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx).
+ //
+ if ((n > 2 && s[1] == ':' && s[2] != '\\' && s[2] != '/') ||
+ (n > 1 && s[0] == '\\' && s[1] == '\\'))
+ throw invalid_basic_path<C> (s);
+#endif
+
// Strip trailing slashes except for the case where the single
// slash represents the root directory.
//
- size_type n (s.size ());
for (; n > 1 && traits::is_separator (s[n - 1]); --n) ;
if (n != s.size ())