From 15d72ec56605be9110aae8d543aec39561e85594 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 10 Jun 2011 23:05:47 +0000 Subject: [PATCH] minor improvement for special cases with --string/--regexp --- lib/request/comparison.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/request/comparison.py b/lib/request/comparison.py index d164e841e..7d6a3a58d 100644 --- a/lib/request/comparison.py +++ b/lib/request/comparison.py @@ -34,17 +34,21 @@ def comparison(page, getRatioValue=False, pageLength=None): seqMatcher = getCurrentThreadData().seqMatcher seqMatcher.set_seq1(kb.pageTemplate) + if any([conf.string, conf.regexp]): + if page: + # String to match in page when the query is valid + if conf.string: + condition = conf.string in page + return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO) + + # Regular expression to match in page when the query is valid + if conf.regexp: + condition = re.search(conf.regexp, page, re.I | re.M) is not None + return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO) + else: + return None + if page: - # String to match in page when the query is valid - if conf.string: - condition = conf.string in page - return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO) - - # Regular expression to match in page when the query is valid - if conf.regexp: - condition = re.search(conf.regexp, page, re.I | re.M) is not None - return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO) - # In case of an DBMS error page return None if kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()): return None