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

Skip to content

Commit a52dbc5

Browse files
committed
Patch for an Issue #246
1 parent f305dde commit a52dbc5

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

lib/controller/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def start():
300300
if conf.cookie:
301301
message += "\nCookie: %s" % conf.cookie
302302

303-
if conf.data:
303+
if conf.data is not None:
304304
message += "\nPOST data: %s" % urlencode(conf.data) if conf.data else ""
305305

306306
if conf.forms:

lib/core/option.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ def __setHTTPMethod():
11101110
Check and set the HTTP method to perform HTTP requests through.
11111111
"""
11121112

1113-
conf.method = HTTPMETHOD.POST if conf.data else HTTPMETHOD.GET
1113+
conf.method = HTTPMETHOD.POST if conf.data is not None else HTTPMETHOD.GET
11141114

11151115
debugMsg = "setting the HTTP method to %s" % conf.method
11161116
logger.debug(debugMsg)

lib/core/target.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ def __setRequestParams():
8080
testableParameters = True
8181

8282
# Perform checks on POST parameters
83-
if conf.method == HTTPMETHOD.POST and not conf.data:
83+
if conf.method == HTTPMETHOD.POST and conf.data is None:
8484
errMsg = "HTTP POST method depends on HTTP data value to be posted"
8585
raise sqlmapSyntaxException, errMsg
8686

87-
if conf.data:
87+
if conf.data is not None:
8888
conf.method = HTTPMETHOD.POST
8989

9090
if CUSTOM_INJECTION_MARK_CHAR in conf.data: # later processed

lib/request/connect.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def getPage(**kwargs):
210210
page = None
211211

212212
_ = urlparse.urlsplit(url)
213-
requestMsg = u"HTTP request [#%d]:\n%s " % (threadData.lastRequestUID, method or (HTTPMETHOD.POST if post else HTTPMETHOD.GET))
213+
requestMsg = u"HTTP request [#%d]:\n%s " % (threadData.lastRequestUID, method or (HTTPMETHOD.POST if post is not None else HTTPMETHOD.GET))
214214
requestMsg += ("%s%s" % (_.path or "/", ("?%s" % _.query) if _.query else "")) if not any((refreshing, crawling)) else url
215215
responseMsg = u"HTTP response "
216216
requestHeaders = u""
@@ -291,7 +291,7 @@ def getPage(**kwargs):
291291
headers[HTTPHEADER.ACCEPT_ENCODING] = HTTP_ACCEPT_ENCODING_HEADER_VALUE if method != HTTPMETHOD.HEAD and kb.pageCompress else "identity"
292292
headers[HTTPHEADER.HOST] = host or getHostHeader(url)
293293

294-
if post and HTTPHEADER.CONTENT_TYPE not in headers:
294+
if post is not None and HTTPHEADER.CONTENT_TYPE not in headers:
295295
headers[HTTPHEADER.CONTENT_TYPE] = POST_HINT_CONTENT_TYPES.get(kb.postHint, DEFAULT_CONTENT_TYPE)
296296

297297
if headers.get(HTTPHEADER.CONTENT_TYPE) == POST_HINT_CONTENT_TYPES[POST_HINT.MULTIPART]:
@@ -326,7 +326,7 @@ def getPage(**kwargs):
326326
cookies = conf.cj._cookies_for_request(req)
327327
requestHeaders += "\n%s" % ("Cookie: %s" % ";".join("%s=%s" % (getUnicode(cookie.name), getUnicode(cookie.value)) for cookie in cookies))
328328

329-
if post:
329+
if post is not None:
330330
if not getRequestHeader(req, HTTPHEADER.CONTENT_LENGTH):
331331
requestHeaders += "\n%s: %d" % (string.capwords(HTTPHEADER.CONTENT_LENGTH), len(post))
332332

@@ -335,7 +335,7 @@ def getPage(**kwargs):
335335

336336
requestMsg += "\n%s" % requestHeaders
337337

338-
if post:
338+
if post is not None:
339339
requestMsg += "\n\n%s" % getUnicode(post)
340340

341341
requestMsg += "\n"
@@ -689,13 +689,13 @@ def _randomizeParameter(paramString, randomParameter):
689689
get = re.sub("((\A|\W)%s=)([^%s]+)" % (name, delimiter), "\g<1>%s" % value, get)
690690
elif '%s=' % name in (post or ""):
691691
post = re.sub("((\A|\W)%s=)([^%s]+)" % (name, delimiter), "\g<1>%s" % value, post)
692-
elif post:
692+
elif post is not None:
693693
post += "%s%s=%s" % (delimiter, name, value)
694694
else:
695695
get += "%s%s=%s" % (delimiter, name, value)
696696

697697
get = urlencode(get, limit=True)
698-
if post:
698+
if post is not None:
699699
if place not in (PLACE.POST, PLACE.CUSTOM_POST) and hasattr(post, UNENCODED_ORIGINAL_VALUE):
700700
post = getattr(post, UNENCODED_ORIGINAL_VALUE)
701701
elif not skipUrlEncode and kb.postHint not in POST_HINT_CONTENT_TYPES.keys():

0 commit comments

Comments
 (0)