From 8c68d25b391411269cd59b846f06d087f80c7f24 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Fri, 26 Feb 2010 12:00:47 +0000 Subject: [PATCH] Major bug fix, be careful when editing isWindowsPath() and normalizePath() in common.py, they can break all --- lib/core/common.py | 9 ++++++++- plugins/generic/misc.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index b9ad2f645..43c4535ad 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -871,11 +871,18 @@ def directoryPath(path): return retVal def normalizePath(path): + """ + This function must be called only after posixToNtSlashes() + and ntToPosixSlashes() + """ + retVal = None + if isWindowsPath(path): retVal = ntpath.normpath(path) else: retVal = posixpath.normpath(path) + return retVal def safeStringFormat(formatStr, params): @@ -927,7 +934,7 @@ def decloakToMkstemp(filepath, **kwargs): return retVal def isWindowsPath(filepath): - return re.search("\A[A-Za-z]:", filepath) is not None + return re.search("\A[\w]\:\\\\", filepath) is not None def posixToNtSlashes(filepath): return filepath.replace('/', '\\') diff --git a/plugins/generic/misc.py b/plugins/generic/misc.py index 88bcc7040..162d26ae0 100644 --- a/plugins/generic/misc.py +++ b/plugins/generic/misc.py @@ -65,7 +65,7 @@ class Miscellaneous: else: conf.tmpPath = "/tmp" - if re.search("^[\w]\:[\/\\\\]+", conf.tmpPath, re.I): + if re.search("\A[\w]:[\/\\\\]+", conf.tmpPath, re.I): kb.os = "Windows" conf.tmpPath = ntToPosixSlashes(conf.tmpPath)