From fb7f2bb1b6a5e7a4bf771fea0f861642fad4c4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Tue, 22 Jan 2019 20:01:18 +0100 Subject: [PATCH] Fix several DeprecationWarning: invalid escape sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mickaƫl Schoentgen --- lib/controller/checks.py | 2 +- lib/core/common.py | 8 ++++---- lib/core/testing.py | 2 +- lib/utils/api.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index cea5a4652..cceb87093 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -1592,7 +1592,7 @@ def checkConnection(suppressOutput=False): conf.url = re.sub(r"https?://", "https://", conf.url) match = re.search(r":(\d+)", threadData.lastRedirectURL[1]) port = match.group(1) if match else 443 - conf.url = re.sub(r":\d+(/|\Z)", ":%s\g<1>" % port, conf.url) + conf.url = re.sub(r":\d+(/|\Z)", r":%s\g<1>" % port, conf.url) except SqlmapConnectionException as ex: if conf.ipv6: diff --git a/lib/core/common.py b/lib/core/common.py index f9fa6add2..7da7f7f93 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1551,7 +1551,7 @@ def expandAsteriskForColumns(expression): if expression != conf.query: conf.db = db else: - expression = re.sub(r"([^\w])%s" % re.escape(conf.tbl), "\g<1>%s.%s" % (conf.db, conf.tbl), expression) + expression = re.sub(r"([^\w])%s" % re.escape(conf.tbl), r"\g<1>%s.%s" % (conf.db, conf.tbl), expression) else: conf.db = db @@ -1950,18 +1950,18 @@ def isWindowsDriveLetterPath(filepath): return re.search(r"\A[\w]\:", filepath) is not None def posixToNtSlashes(filepath): - """ + r""" Replaces all occurrences of Posix slashes (/) in provided filepath with NT ones (\) >>> posixToNtSlashes('C:/Windows') - 'C:\\\\Windows' + 'C:\\Windows' """ return filepath.replace('/', '\\') if filepath else filepath def ntToPosixSlashes(filepath): - """ + r""" Replaces all occurrences of NT slashes (\) in provided filepath with Posix ones (/) diff --git a/lib/core/testing.py b/lib/core/testing.py index 030f58f39..b4ecff7c3 100644 --- a/lib/core/testing.py +++ b/lib/core/testing.py @@ -323,7 +323,7 @@ def replaceVars(item, vars_): retVal = item if item and vars_: - for var in re.findall("\$\{([^}]+)\}", item): + for var in re.findall(r"\$\{([^}]+)\}", item): if var in vars_: retVal = retVal.replace("${%s}" % var, vars_[var]) diff --git a/lib/utils/api.py b/lib/utils/api.py index ae971efe7..17b62cf36 100644 --- a/lib/utils/api.py +++ b/lib/utils/api.py @@ -734,7 +734,7 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non DataStore.password = password dbgMsg = "Example client access from command line:" - dbgMsg += "\n\t$ taskid=$(curl http://%s:%d/task/new 2>1 | grep -o -I '[a-f0-9]\{16\}') && echo $taskid" % (host, port) + dbgMsg += r"\n\t$ taskid=$(curl http://%s:%d/task/new 2>1 | grep -o -I '[a-f0-9]\{16\}') && echo $taskid" % (host, port) dbgMsg += "\n\t$ curl -H \"Content-Type: application/json\" -X POST -d '{\"url\": \"http://testphp.vulnweb.com/artists.php?artist=1\"}' http://%s:%d/scan/$taskid/start" % (host, port) dbgMsg += "\n\t$ curl http://%s:%d/scan/$taskid/data" % (host, port) dbgMsg += "\n\t$ curl http://%s:%d/scan/$taskid/log" % (host, port)