From 044f05e772d0787489bdf7bc220a5dfc76714b1d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 24 Oct 2016 23:52:33 +0200 Subject: [PATCH] Fixes #2246 --- lib/core/common.py | 27 +++++++++++++++++++-------- lib/core/settings.py | 2 +- txt/checksum.md5 | 4 ++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/core/common.py b/lib/core/common.py index 6af7976fa..a61273b23 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -931,15 +931,26 @@ def dataToOutFile(filename, data): retVal = None if data: - retVal = os.path.join(conf.filePath, filePathToSafeString(filename)) + while True: + retVal = os.path.join(conf.filePath, filePathToSafeString(filename)) - try: - with open(retVal, "w+b") as f: # has to stay as non-codecs because data is raw ASCII encoded data - f.write(unicodeencode(data)) - except IOError, ex: - errMsg = "something went wrong while trying to write " - errMsg += "to the output file ('%s')" % getSafeExString(ex) - raise SqlmapGenericException(errMsg) + try: + with open(retVal, "w+b") as f: # has to stay as non-codecs because data is raw ASCII encoded data + f.write(unicodeencode(data)) + except UnicodeEncodeError, ex: + _ = normalizeUnicode(filename) + if filename != _: + filename = _ + else: + errMsg = "couldn't write to the " + errMsg += "output file ('%s')" % getSafeExString(ex) + raise SqlmapGenericException(errMsg) + except IOError, ex: + errMsg = "something went wrong while trying to write " + errMsg += "to the output file ('%s')" % getSafeExString(ex) + raise SqlmapGenericException(errMsg) + else: + break return retVal diff --git a/lib/core/settings.py b/lib/core/settings.py index e863c8208..8c97d5784 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.0.10.56" +VERSION = "1.0.10.57" 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 53efa6830..b83a63e19 100644 --- a/txt/checksum.md5 +++ b/txt/checksum.md5 @@ -26,7 +26,7 @@ ec007a1424da78cfdae90da6ae49ed9b lib/controller/handler.py cc9c82cfffd8ee9b25ba3af6284f057e lib/controller/__init__.py 04f16204c899438dc7599a9a8426bfee lib/core/agent.py eb0bd28b0bd9fbf67dcc3119116df377 lib/core/bigarray.py -8d32e43491ab8d7082dadd3155e6a9fb lib/core/common.py +136246c879e7a15309ed892ea4c1c3eb lib/core/common.py 5680d0c446a3bed5c0f2a0402d031557 lib/core/convert.py e77cca1cb063016f71f6e6bdebf4ec73 lib/core/data.py 1d042f0bc0557d3fd564ea5a46deb77e lib/core/datatype.py @@ -45,7 +45,7 @@ e60456db5380840a586654344003d4e6 lib/core/readlineng.py 5ef56abb8671c2ca6ceecb208258e360 lib/core/replication.py 99a2b496b9d5b546b335653ca801153f lib/core/revision.py 7c15dd2777af4dac2c89cab6df17462e lib/core/session.py -af794f90e9c1a317e3a2873b0e10a40f lib/core/settings.py +a26c40b76c7ec1f18b004790c31bdbeb lib/core/settings.py 7af83e4f18cab6dff5e67840eb65be80 lib/core/shell.py 23657cd7d924e3c6d225719865855827 lib/core/subprocessng.py c3ace7874a536d801f308cf1fd03df99 lib/core/target.py