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

Skip to content

Commit 15d72ec

Browse files
committed
minor improvement for special cases with --string/--regexp
1 parent 8fac460 commit 15d72ec

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

lib/request/comparison.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,21 @@ def comparison(page, getRatioValue=False, pageLength=None):
3434
seqMatcher = getCurrentThreadData().seqMatcher
3535
seqMatcher.set_seq1(kb.pageTemplate)
3636

37-
if page:
38-
# String to match in page when the query is valid
39-
if conf.string:
40-
condition = conf.string in page
41-
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
42-
43-
# Regular expression to match in page when the query is valid
44-
if conf.regexp:
45-
condition = re.search(conf.regexp, page, re.I | re.M) is not None
46-
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
37+
if any([conf.string, conf.regexp]):
38+
if page:
39+
# String to match in page when the query is valid
40+
if conf.string:
41+
condition = conf.string in page
42+
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
43+
44+
# Regular expression to match in page when the query is valid
45+
if conf.regexp:
46+
condition = re.search(conf.regexp, page, re.I | re.M) is not None
47+
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
48+
else:
49+
return None
4750

51+
if page:
4852
# In case of an DBMS error page return None
4953
if kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()):
5054
return None

0 commit comments

Comments
 (0)