mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-24 08:14:24 +03:00
minor update regarding mnemonics (again)
This commit is contained in:
parent
286e7ee679
commit
7733e5866a
|
@ -2631,11 +2631,13 @@ def expandMnemonics(mnemonics, parser, args):
|
||||||
for option in group.option_list:
|
for option in group.option_list:
|
||||||
for opt in option._long_opts + option._short_opts:
|
for opt in option._long_opts + option._short_opts:
|
||||||
pointer = head
|
pointer = head
|
||||||
|
|
||||||
for char in opt:
|
for char in opt:
|
||||||
if char == "-":
|
if char == "-":
|
||||||
continue
|
continue
|
||||||
elif char not in pointer.next:
|
elif char not in pointer.next:
|
||||||
pointer.next[char] = MnemonicNode()
|
pointer.next[char] = MnemonicNode()
|
||||||
|
|
||||||
pointer = pointer.next[char]
|
pointer = pointer.next[char]
|
||||||
pointer.current.append(option)
|
pointer.current.append(option)
|
||||||
|
|
||||||
|
@ -2644,6 +2646,7 @@ def expandMnemonics(mnemonics, parser, args):
|
||||||
name = mnemonic.split('=')[0].replace("-", "").strip()
|
name = mnemonic.split('=')[0].replace("-", "").strip()
|
||||||
value = mnemonic.split('=')[1] if len(mnemonic.split('=')) > 1 else None
|
value = mnemonic.split('=')[1] if len(mnemonic.split('=')) > 1 else None
|
||||||
pointer = head
|
pointer = head
|
||||||
|
|
||||||
for char in name:
|
for char in name:
|
||||||
if char in pointer.next:
|
if char in pointer.next:
|
||||||
pointer = pointer.next[char]
|
pointer = pointer.next[char]
|
||||||
|
@ -2654,20 +2657,26 @@ def expandMnemonics(mnemonics, parser, args):
|
||||||
if pointer in (None, head):
|
if pointer in (None, head):
|
||||||
errMsg = "mnemonic '%s' can't be resolved to any parameter name" % name
|
errMsg = "mnemonic '%s' can't be resolved to any parameter name" % name
|
||||||
raise sqlmapSyntaxException, errMsg
|
raise sqlmapSyntaxException, errMsg
|
||||||
|
|
||||||
elif len(pointer.current) > 1:
|
elif len(pointer.current) > 1:
|
||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
for option in pointer.current:
|
for option in pointer.current:
|
||||||
for opt in option._long_opts + option._short_opts:
|
for opt in option._long_opts + option._short_opts:
|
||||||
options[opt.strip('-')] = option
|
opt = opt.strip('-')
|
||||||
|
if opt.startswith(name):
|
||||||
|
options[opt] = option
|
||||||
|
|
||||||
if name in options:
|
if name in options:
|
||||||
found = name
|
found = name
|
||||||
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
|
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
else:
|
else:
|
||||||
found = sorted(options.keys(), key=lambda x: len(x))[0]
|
found = sorted(options.keys(), key=lambda x: len(x))[0]
|
||||||
warnMsg = "detected ambiguity (mnemonic '%s' can be resolved to %s). " % (name, ", ".join(options.keys()))
|
warnMsg = "detected ambiguity (mnemonic '%s' can be resolved to %s). " % (name, ", ".join("'%s'" % key for key in options.keys()))
|
||||||
warnMsg += "resolved to shortest parameter name (%s)" % found
|
warnMsg += "resolved to shortest of those available ('%s')" % found
|
||||||
logger.warn(warnMsg)
|
logger.warn(warnMsg)
|
||||||
|
|
||||||
found = options[found]
|
found = options[found]
|
||||||
else:
|
else:
|
||||||
found = pointer.current[0]
|
found = pointer.current[0]
|
||||||
|
@ -2676,6 +2685,7 @@ def expandMnemonics(mnemonics, parser, args):
|
||||||
|
|
||||||
if found:
|
if found:
|
||||||
value = found.convert_value(found, value)
|
value = found.convert_value(found, value)
|
||||||
|
|
||||||
if value is not None:
|
if value is not None:
|
||||||
setattr(args, found.dest, value)
|
setattr(args, found.dest, value)
|
||||||
elif not found.type: # boolean
|
elif not found.type: # boolean
|
||||||
|
|
Loading…
Reference in New Issue
Block a user