Skip to content

Commit

Permalink
Update MadApkEndpoint.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JabLuszko authored Sep 20, 2024
1 parent b7d84ae commit e9098d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mapadroid/madmin/endpoints/api/apks/MadApkEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ async def get(self):
except KeyError:
return await self._json_response(data=data[apk_type])

def allowed_file(filename):
ALLOWED_EXTENSIONS = set(['apk', 'apkm', 'zip'])
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS

async def post(self):
apk_type_raw: str = self.request.match_info.get('apk_type')
apk_arch_raw: str = self.request.match_info.get('apk_arch')
Expand All @@ -58,7 +62,7 @@ async def post(self):
elif not file.filename:
await self._add_notice_message('No file selected for uploading')
raise web.HTTPFound(self._url_for("upload"))
elif not allowed_file(file.filename):
elif not self.allowed_file(file.filename):
await self._add_notice_message('Allowed file type is apk only!')
raise web.HTTPFound(self._url_for("upload"))
filename = secure_filename(file.filename)
Expand Down

0 comments on commit e9098d7

Please sign in to comment.