From e7b033d7b38bc55f934521b5f35060b43a8b0526 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 30 Nov 2016 11:47:27 +0300 Subject: Make path::normalize() to preserve ./, invalidate paths starting with \, / on Windows --- butl/process.cxx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'butl/process.cxx') diff --git a/butl/process.cxx b/butl/process.cxx index c75cfbd..cf4b26d 100644 --- a/butl/process.cxx +++ b/butl/process.cxx @@ -171,7 +171,7 @@ namespace butl ep = path (move (s)); // Move back into result. if (norm) - ep.normalize (); //@@ NORM + ep.normalize (); return exists (ep.string ().c_str ()); }; @@ -212,10 +212,17 @@ namespace butl e = strchr (b, traits::path_separator); // Empty path (i.e., a double colon or a colon at the beginning or end - // of PATH) means search in the current dirrectory. + // of PATH) means search in the current dirrectory. Silently skip + // invalid paths. // - if (search (b, e != nullptr ? e - b : strlen (b))) - return r; + try + { + if (search (b, e != nullptr ? e - b : strlen (b))) + return r; + } + catch (const invalid_path&) + { + } } // If we were given a fallback, try that. @@ -575,10 +582,17 @@ namespace butl e = strchr (b, traits::path_separator); // Empty path (i.e., a double colon or a colon at the beginning or end - // of PATH) means search in the current dirrectory. + // of PATH) means search in the current dirrectory. Silently skip + // invalid paths. // - if (search (b, e != nullptr ? e - b : strlen (b))) - return r; + try + { + if (search (b, e != nullptr ? e - b : strlen (b))) + return r; + } + catch (const invalid_path&) + { + } } // Finally, if we were given a fallback, try that. This case is similar to -- cgit v1.1