Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 28eca21

Browse files
committed
Fix for an Issue #513
1 parent 7cb3ea2 commit 28eca21

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

lib/core/common.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,6 +3365,27 @@ def checkDeprecatedOptions(args):
33653365
errMsg += " (hint: %s)" % DEPRECATED_OPTIONS[_]
33663366
raise SqlmapSyntaxException(errMsg)
33673367

3368+
def checkSystemEncoding():
3369+
"""
3370+
Checks for problematic encodings
3371+
"""
3372+
3373+
if sys.getdefaultencoding() == "cp720":
3374+
try:
3375+
codecs.lookup("cp720")
3376+
except LookupError:
3377+
errMsg = "there is a known Python issue (#1616979) related "
3378+
errMsg += "to support for charset 'cp720'. Please visit "
3379+
errMsg += "'http://blog.oneortheother.info/tip/python-fix-cp720-encoding/index.html' "
3380+
errMsg += "and follow the instructions to be able to fix it"
3381+
logger.critical(errMsg)
3382+
3383+
warnMsg = "temporary switching to charset 'cp1256'"
3384+
logger.warn(warnMsg)
3385+
3386+
reload(sys)
3387+
sys.setdefaultencoding("cp1256")
3388+
33683389
def evaluateCode(code, variables=None):
33693390
"""
33703391
Executes given python code given in a string form

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
See the file 'doc/COPYING' for copying permission
66
"""
77

8+
import codecs
89
import sys
910

1011
from optparse import OptionError
@@ -13,6 +14,7 @@
1314
from optparse import SUPPRESS_HELP
1415

1516
from lib.core.common import checkDeprecatedOptions
17+
from lib.core.common import checkSystemEncoding
1618
from lib.core.common import expandMnemonics
1719
from lib.core.common import getUnicode
1820
from lib.core.data import logger
@@ -28,6 +30,8 @@ def cmdLineParser():
2830
This function parses the command line parameters and arguments
2931
"""
3032

33+
checkSystemEncoding()
34+
3135
usage = "%s%s [options]" % ("python " if not IS_WIN else "", \
3236
"\"%s\"" % sys.argv[0] if " " in sys.argv[0] else sys.argv[0])
3337

0 commit comments

Comments
 (0)