21
21
from lib .core .data import kb
22
22
from lib .core .data import logger
23
23
from lib .core .exception import SqlmapNoneDataException
24
+ from lib .core .exception import SqlmapSilentQuitException
24
25
from lib .core .settings import DEFAULT_PAGE_ENCODING
26
+ from lib .core .settings import DEV_EMAIL_ADDRESS
25
27
from lib .core .settings import DIFF_TOLERANCE
26
28
from lib .core .settings import HTML_TITLE_REGEX
27
29
from lib .core .settings import LOWER_RATIO_BOUND
35
37
from thirdparty import six
36
38
37
39
def 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
40
48
41
49
def _adjust (condition , getRatioValue ):
42
50
if not any ((conf .string , conf .notString , conf .regexp , conf .code )):
@@ -120,7 +128,7 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
120
128
if isinstance (seqMatcher .a , six .binary_type ) and isinstance (page , six .text_type ):
121
129
page = getBytes (page , kb .pageEncoding or DEFAULT_PAGE_ENCODING , "ignore" )
122
130
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" ) )
124
132
125
133
if any (_ is None for _ in (page , seqMatcher .a )):
126
134
return None
@@ -146,12 +154,19 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
146
154
if seq1 is None or seq2 is None :
147
155
return None
148
156
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 , "" )
151
166
152
167
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 " )
155
170
156
171
key = None
157
172
else :
0 commit comments