Skip to content

Commit c9e7e71

Browse files
committed
Implementation for an Issue sqlmapproject#195
1 parent 9ca7b3e commit c9e7e71

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

lib/core/option.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
from lib.core.update import update
118118
from lib.parse.configfile import configFileParser
119119
from lib.parse.payloads import loadPayloads
120+
from lib.request.basic import checkCharEncoding
120121
from lib.request.connect import Connect as Request
121122
from lib.request.dns import DNSServer
122123
from lib.request.proxy import ProxyHTTPSHandler
@@ -1965,13 +1966,14 @@ def __basicOptionValidation():
19651966
raise sqlmapSyntaxException, errMsg
19661967

19671968
if conf.charset:
1968-
try:
1969-
codecs.lookup(conf.charset)
1970-
except LookupError:
1969+
_ = checkCharEncoding(conf.charset, False)
1970+
if _ is None:
19711971
errMsg = "unknown charset '%s'. Please visit " % conf.charset
19721972
errMsg += "'%s' to get the full list of " % CODECS_LIST_PAGE
19731973
errMsg += "supported charsets"
19741974
raise sqlmapSyntaxException, errMsg
1975+
else:
1976+
conf.charset = _
19751977

19761978
if conf.loadCookies:
19771979
if not os.path.exists(conf.loadCookies):

lib/request/basic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ def parseResponse(page, headers):
100100
if page:
101101
htmlParser(page)
102102

103-
def checkCharEncoding(encoding):
103+
def checkCharEncoding(encoding, warn=True):
104104
if encoding:
105105
encoding = encoding.lower()
106106
else:
107107
return encoding
108108

109109
# http://www.destructor.de/charsets/index.htm
110-
translate = { "windows-874": "iso-8859-11", "en_us": "utf8", "macintosh": "iso-8859-1", "euc_tw": "big5_tw", "th": "tis-620", "unicode": "utf8", "utc8": "utf8"}
110+
translate = { "windows-874": "iso-8859-11", "en_us": "utf8", "macintosh": "iso-8859-1", "euc_tw": "big5_tw", "th": "tis-620", "unicode": "utf8", "utc8": "utf8", "ebcdic": "ebcdic-cp-be"}
111111

112112
for delimiter in (';', ',', '('):
113113
if delimiter in encoding:
@@ -156,9 +156,10 @@ def checkCharEncoding(encoding):
156156
try:
157157
codecs.lookup(encoding)
158158
except LookupError:
159-
warnMsg = "unknown web page charset '%s'. " % encoding
160-
warnMsg += "Please report by e-mail to %s." % ML
161-
singleTimeLogMessage(warnMsg, logging.WARN, encoding)
159+
if warn:
160+
warnMsg = "unknown web page charset '%s'. " % encoding
161+
warnMsg += "Please report by e-mail to %s." % ML
162+
singleTimeLogMessage(warnMsg, logging.WARN, encoding)
162163
encoding = None
163164

164165
return encoding

0 commit comments

Comments
 (0)