From f38596a5b30b890cc1f2aa4daf62a8e1799cd9d3 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 20 Feb 2018 14:02:02 +0100 Subject: [PATCH] Minor refactoring --- lib/core/common.py | 17 ++++++++++++++++- lib/core/settings.py | 2 +- txt/checksum.md5 | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 67631b110..f81cb1df9 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -889,6 +889,21 @@ def setColor(message, bold=False): return retVal +def clearColors(message): + """ + Clears ANSI color codes + + >>> clearColors("\x1b[38;5;82mHello \x1b[38;5;198mWorld") + 'Hello World' + """ + + retVal = message + + if message: + retVal = re.sub(r"\x1b\[[\d;]+m", "", message) + + return retVal + def dataToStdout(data, forceOutput=False, bold=False, content_type=None, status=CONTENT_STATUS.IN_PROGRESS): """ Writes text to the stdout (console) stream @@ -1178,7 +1193,7 @@ def banner(): _ = BANNER if not getattr(LOGGER_HANDLER, "is_tty", False) or "--disable-coloring" in sys.argv: - _ = re.sub("\033.+?m", "", _) + _ = clearColors(_) elif IS_WIN: coloramainit() diff --git a/lib/core/settings.py b/lib/core/settings.py index faa3b38ff..625e335ec 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import OS # sqlmap version (...) -VERSION = "1.2.2.13" +VERSION = "1.2.2.14" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/txt/checksum.md5 b/txt/checksum.md5 index 050b6f121..3a13b83de 100644 --- a/txt/checksum.md5 +++ b/txt/checksum.md5 @@ -27,7 +27,7 @@ a7b0c8e5a18a3abe8803999dcfc4664f lib/controller/handler.py 1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py e3a3f5218b2e52dd0afafdfc9fed2002 lib/core/agent.py 86a4703d5474badd8462146510b2c460 lib/core/bigarray.py -17ab0324cb992a781cc197ec8c0209d7 lib/core/common.py +32a77cc3fc2d26d26f469ab8eb35efed lib/core/common.py 2a40d5b5997265daa890545d4a4a59b9 lib/core/convert.py 9f87391b6a3395f7f50830b391264f27 lib/core/data.py 72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py @@ -46,7 +46,7 @@ ffa5f01f39b17c8d73423acca6cfe86a lib/core/readlineng.py 0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py a7db43859b61569b601b97f187dd31c5 lib/core/revision.py fcb74fcc9577523524659ec49e2e964b lib/core/session.py -7735e472a2d2661744bd6d04fd1c387d lib/core/settings.py +feb9124da962dd30ab7fcecc4a60f5d3 lib/core/settings.py d0adc28a38e43a787df4471f7f027413 lib/core/shell.py 63491be462c515a1a3880c27c2acc4a2 lib/core/subprocessng.py 505aaa61e1bba3c3d4567c3e667699e3 lib/core/target.py