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

Skip to content

Commit 2a1e812

Browse files
committed
Some more Python 3.9 patching
1 parent 44b7cc7 commit 2a1e812

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

lib/parse/payloads.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def parseXmlNode(node):
4444
for element in node.findall("boundary"):
4545
boundary = AttribDict()
4646

47-
for child in element.getchildren():
47+
for child in element:
4848
if child.text:
4949
values = cleanupVals(child.text, child.tag)
5050
boundary[child.tag] = values
@@ -56,18 +56,18 @@ def parseXmlNode(node):
5656
for element in node.findall("test"):
5757
test = AttribDict()
5858

59-
for child in element.getchildren():
59+
for child in element:
6060
if child.text and child.text.strip():
6161
values = cleanupVals(child.text, child.tag)
6262
test[child.tag] = values
6363
else:
64-
if len(child.getchildren()) == 0:
64+
if len(child.findall("*")) == 0:
6565
test[child.tag] = None
6666
continue
6767
else:
6868
test[child.tag] = AttribDict()
6969

70-
for gchild in child.getchildren():
70+
for gchild in child:
7171
if gchild.tag in test[child.tag]:
7272
prevtext = test[child.tag][gchild.tag]
7373
test[child.tag][gchild.tag] = [prevtext, gchild.text]
@@ -77,6 +77,15 @@ def parseXmlNode(node):
7777
conf.tests.append(test)
7878

7979
def loadBoundaries():
80+
"""
81+
Loads boundaries from XML
82+
83+
>>> conf.boundaries = []
84+
>>> loadBoundaries()
85+
>>> len(conf.boundaries) > 0
86+
True
87+
"""
88+
8089
try:
8190
doc = et.parse(paths.BOUNDARIES_XML)
8291
except Exception as ex:
@@ -89,6 +98,15 @@ def loadBoundaries():
8998
parseXmlNode(root)
9099

91100
def loadPayloads():
101+
"""
102+
Loads payloads/tests from XML
103+
104+
>>> conf.tests = []
105+
>>> loadPayloads()
106+
>>> len(conf.tests) > 0
107+
True
108+
"""
109+
92110
for payloadFile in PAYLOAD_XML_FILES:
93111
payloadFilePath = os.path.join(paths.SQLMAP_XML_PAYLOADS_PATH, payloadFile)
94112

0 commit comments

Comments
 (0)