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

Skip to content

Commit 1418ae9

Browse files
committed
little refactoring of parseUnionPage together with a patch for some special case
1 parent 7fb1f3f commit 1418ae9

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

lib/core/common.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,27 +1178,27 @@ def getLimitRange(count, dump=False, plusOne=False):
11781178

11791179
return retVal
11801180

1181-
def parseUnionPage(output, unique=True):
1181+
def parseUnionPage(page, unique=True):
11821182
"""
11831183
Returns resulting items from inband query inside provided page content
11841184
"""
11851185

1186-
if output is None:
1186+
if page is None:
11871187
return None
11881188

1189-
if output.startswith(kb.chars.start) and output.endswith(kb.chars.stop):
1190-
if len(output) > LARGE_OUTPUT_THRESHOLD:
1189+
if page.startswith(kb.chars.start) and page.endswith(kb.chars.stop):
1190+
if len(page) > LARGE_OUTPUT_THRESHOLD:
11911191
warnMsg = "large output detected. This might take a while"
11921192
logger.warn(warnMsg)
11931193

11941194
data = BigArray()
11951195
_ = []
11961196

1197-
regExpr = '%s(.*?)%s' % (kb.chars.start, kb.chars.stop)
1198-
output = re.finditer(regExpr, output, re.DOTALL | re.IGNORECASE)
1197+
for match in re.finditer("%s(.*?)%s" % (kb.chars.start, kb.chars.stop), page, re.DOTALL | re.IGNORECASE):
1198+
entry = match.group(1)
11991199

1200-
for entry in output:
1201-
entry = entry.group(1)
1200+
if kb.chars.start in entry:
1201+
entry = entry.split(kb.chars.start)[-1]
12021202

12031203
if unique:
12041204
key = entry.lower()
@@ -1219,7 +1219,7 @@ def parseUnionPage(output, unique=True):
12191219

12201220
data.append(entry[0] if len(entry) == 1 else entry)
12211221
else:
1222-
data = output
1222+
data = page
12231223

12241224
if len(data) == 1 and isinstance(data[0], basestring):
12251225
data = data[0]

0 commit comments

Comments
 (0)