You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
For some reason (I was not able to identify which one exactly), the response form fortiguard.com is transfered as a binary string to re.search() which crashes as follows:
Fortiguard/urlcategory.py <<<'{"data":"http://trello.com","dataType":"url"}'
Traceback (most recent call last):
File "./urlcategory.py", line 54, in<module>URLCategoryAnalyzer().run()
File "./urlcategory.py", line 43, in run
category_match = re.search(pattern, req.content, flags=0)
File "/usr/local/lib/python3.7/re.py", line 183, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object
Using req.text instead of req.content fixed the issue.
To Reproduce
Steps to reproduce the behavior:
execute ./Fortiguard/urlcategory <<< '{"data":"http://trello.com/", "dataType":"url"}' (URL does not matter)
wiat for the crash
I was not able to reproduce it on my laptop but this always generate a crash on our production server. I don't know if this comes from python dependencies, server environment or other stuff...
Expected behavior
Expect to have a successful result.
Complementary information
When adding a print(req.content) juste after executing the query, the result looks like the following:
Describe the bug
For some reason (I was not able to identify which one exactly), the response form fortiguard.com is transfered as a binary string to
re.search()
which crashes as follows:Using
req.text
instead ofreq.content
fixed the issue.To Reproduce
Steps to reproduce the behavior:
./Fortiguard/urlcategory <<< '{"data":"http://trello.com/", "dataType":"url"}'
(URL does not matter)I was not able to reproduce it on my laptop but this always generate a crash on our production server. I don't know if this comes from python dependencies, server environment or other stuff...
Expected behavior
Expect to have a successful result.
Complementary information
When adding a
print(req.content)
juste after executing the query, the result looks like the following:Work environment
Possible solutions
req.text
instead ofreq.content
when passing the result of the query tore.search()
try ... catch
to handle binary formatThe text was updated successfully, but these errors were encountered: