mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Redirect to home on invalid book id
This commit is contained in:
parent
38a1bf50d8
commit
3eca4a53d0
@ -254,9 +254,13 @@ def mobile(ctx, rd):
|
|||||||
@endpoint('/browse/{+rest=""}')
|
@endpoint('/browse/{+rest=""}')
|
||||||
def browse(ctx, rd, rest):
|
def browse(ctx, rd, rest):
|
||||||
if rest.startswith('book/'):
|
if rest.startswith('book/'):
|
||||||
|
try:
|
||||||
|
book_id = int(rest[5:])
|
||||||
|
except Exception:
|
||||||
|
raise HTTPRedirect(ctx.url_for(None))
|
||||||
# implementation of https://bugs.launchpad.net/calibre/+bug/1698411
|
# implementation of https://bugs.launchpad.net/calibre/+bug/1698411
|
||||||
# redirect old server book URLs to new URLs
|
# redirect old server book URLs to new URLs
|
||||||
redirect = ctx.url_for(None) + '#book_id=' + int(rest[5:]) + "&panel=book_details"
|
redirect = ctx.url_for(None) + f'#book_id={book_id}&panel=book_details'
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
return html(ctx, rd, endpoint,
|
return html(ctx, rd, endpoint,
|
||||||
E.html(E.head(
|
E.html(E.head(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user