Skip to content

Commit

Permalink
fixed issue with HTML inside XML (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofermend authored Sep 12, 2024
1 parent ac3e76c commit 1bdb76c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def detect_file_type(file_path):
"""
mime = magic.Magic(mime=True)
mime_type = mime.from_file(file_path)
with open(file_path, 'r', encoding='utf-8') as file:
first_1024_bytes = file.read(1024)
if '<html' in first_1024_bytes.lower() and '</html>' in first_1024_bytes.lower():
return 'text/html'
return mime_type

def remove_code_from_html(html: str) -> str:
Expand Down

0 comments on commit 1bdb76c

Please sign in to comment.