From ed0bdbf31d015a7f064d40669a3a9c64f2c27477 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 16 Feb 2020 19:39:32 +0100 Subject: [PATCH] Fix for #1199 (missing referrer) --- cps/shelf.py | 5 ++++- cps/web.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cps/shelf.py b/cps/shelf.py index d405642c..6e8c4b9f 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -179,7 +179,10 @@ def remove_from_shelf(shelf_id, book_id): if not xhr: flash(_(u"Book has been removed from shelf: %(sname)s", sname=shelf.name), category="success") - return redirect(request.environ["HTTP_REFERER"]) + if "HTTP_REFERER" in request.environ: + return redirect(request.environ["HTTP_REFERER"]) + else: + return redirect(url_for('web.index')) return "", 204 else: log.error("User %s not allowed to remove a book from %s", current_user, shelf) diff --git a/cps/web.py b/cps/web.py index 381bb8df..97a3b0be 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1067,7 +1067,10 @@ def send_to_kindle(book_id, book_format, convert): flash(_(u"There was an error sending this book: %(res)s", res=result), category="error") else: flash(_(u"Please configure your kindle e-mail address first..."), category="error") - return redirect(request.environ["HTTP_REFERER"]) + if "HTTP_REFERER" in request.environ: + return redirect(request.environ["HTTP_REFERER"]) + else: + return redirect(url_for('web.index')) # ################################### Login Logout ##################################################################