Skip to content

Commit

Permalink
Fix crash when saving an image (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicteixeira authored Apr 23, 2018
1 parent 13c1bdc commit 6e7af5b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wagtailenforcer/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@


def check_for_virus(instance):
has_virus, name = is_infected(instance.file.read())
if instance.file.closed:
with open(instance.file.path, 'rb') as file:
file_content = file.read()
else:
file_content = file.read()

has_virus, name = is_infected(file_content)

if has_virus:
raise EnforcerVirusException(_('Virus "{}" was detected').format(name))
Expand Down

0 comments on commit 6e7af5b

Please sign in to comment.