2121from lib .core .data import kb
2222from lib .core .data import logger
2323from lib .core .exception import SqlmapNoneDataException
24+ from lib .core .exception import SqlmapSilentQuitException
2425from lib .core .settings import DEFAULT_PAGE_ENCODING
26+ from lib .core .settings import DEV_EMAIL_ADDRESS
2527from lib .core .settings import DIFF_TOLERANCE
2628from lib .core .settings import HTML_TITLE_REGEX
2729from lib .core .settings import LOWER_RATIO_BOUND
3537from thirdparty import six
3638
3739def comparison (page , headers , code = None , getRatioValue = False , pageLength = None ):
38- _ = _adjust (_comparison (page , headers , code , getRatioValue , pageLength ), getRatioValue )
39- return _
40+ try :
41+ _ = _adjust (_comparison (page , headers , code , getRatioValue , pageLength ), getRatioValue )
42+ return _
43+ except :
44+ warnMsg = "there was a KNOWN issue inside the internals regarding the difflib/comparison of pages. "
45+ warnMsg += "Please report details privately via e-mail to '%s'" % DEV_EMAIL_ADDRESS
46+ logger .critical (warnMsg )
47+ raise SqlmapSilentQuitException
4048
4149def _adjust (condition , getRatioValue ):
4250 if not any ((conf .string , conf .notString , conf .regexp , conf .code )):
@@ -120,7 +128,7 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
120128 if isinstance (seqMatcher .a , six .binary_type ) and isinstance (page , six .text_type ):
121129 page = getBytes (page , kb .pageEncoding or DEFAULT_PAGE_ENCODING , "ignore" )
122130 elif isinstance (seqMatcher .a , six .text_type ) and isinstance (page , six .binary_type ):
123- seqMatcher .a = getBytes (seqMatcher .a , kb .pageEncoding or DEFAULT_PAGE_ENCODING , "ignore" )
131+ seqMatcher .set_seq1 ( getBytes (seqMatcher .a , kb .pageEncoding or DEFAULT_PAGE_ENCODING , "ignore" ) )
124132
125133 if any (_ is None for _ in (page , seqMatcher .a )):
126134 return None
@@ -146,12 +154,19 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
146154 if seq1 is None or seq2 is None :
147155 return None
148156
149- seq1 = seq1 .replace (REFLECTED_VALUE_MARKER , "" )
150- seq2 = seq2 .replace (REFLECTED_VALUE_MARKER , "" )
157+ if isinstance (seq1 , six .binary_type ):
158+ seq1 = seq1 .replace (REFLECTED_VALUE_MARKER .encode (), b"" )
159+ elif isinstance (seq1 , six .text_type ):
160+ seq1 = seq1 .replace (REFLECTED_VALUE_MARKER , "" )
161+
162+ if isinstance (seq2 , six .binary_type ):
163+ seq2 = seq2 .replace (REFLECTED_VALUE_MARKER .encode (), b"" )
164+ elif isinstance (seq2 , six .text_type ):
165+ seq2 = seq2 .replace (REFLECTED_VALUE_MARKER , "" )
151166
152167 if kb .heavilyDynamic :
153- seq1 = seq1 .split ("\n " )
154- seq2 = seq2 .split ("\n " )
168+ seq1 = seq1 .split ("\n " if isinstance ( seq1 , six . text_type ) else b" \n " )
169+ seq2 = seq2 .split ("\n " if isinstance ( seq2 , six . text_type ) else b" \n " )
155170
156171 key = None
157172 else :
0 commit comments