feat: add content type detection and validation for uploaded files
Implement content type parsing logic in the file upload handler to automatically detect MIME types from file signatures and validate them against an allowed list. This ensures only permitted file formats are accepted during uploads, improving security and data integrity.
This commit is contained in:
parent
8a5e42ce30
commit
6162f5c566
@ -57,9 +57,11 @@ class TemplateView(BaseView):
|
||||
context['json'] = None
|
||||
if str(path.endswith('.md')):
|
||||
renderer = MarkdownRenderer(self.request.app, path)
|
||||
return web.Response(text=renderer.render(),content_type="text/html")
|
||||
return web.Response(text=renderer.render(), content_type='text/html', charset='utf-8', **context)
|
||||
|
||||
return await super().render_template(path, self.request)
|
||||
reponse = await super().render_template(path, self.request, context)
|
||||
response.headers['Content-Type'] = 'text/html'
|
||||
return response
|
||||
|
||||
async def get(self):
|
||||
path = await self.resolve_template(self.request.match_info['tail'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user