Fix crash when User-Agent header is missing

The download_link endpoint called .lower() on the User-Agent header value without providing a default, causing AttributeError when the header is absent. This matches the safe pattern already used in render_template.py
This commit is contained in:
Ashay
2026-07-07 17:02:59 +05:30
parent e3dd77d34f
commit 1a00f70e62
+2 -2
View File
@@ -1247,9 +1247,9 @@ def serve_book(book_id, book_format, anyname):
@login_required_if_no_ano
@download_required
def download_link(book_id, book_format, anyname):
if "kindle" in request.headers.get('User-Agent').lower():
if "kindle" in request.headers.get('User-Agent', "").lower():
client = "kindle"
elif "Kobo" in request.headers.get('User-Agent').lower():
elif "Kobo" in request.headers.get('User-Agent', "").lower():
client = "kobo"
else:
client = ""