From 11b770b3fb3c03eb6090f8a936d923a686c343ce Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 3 Mar 2019 07:59:44 +0100 Subject: [PATCH] Fix for #830 Fix user with umlauts --- cps/templates/osd.xml | 2 +- cps/web.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/templates/osd.xml b/cps/templates/osd.xml index b88e6823..0c0225d0 100644 --- a/cps/templates/osd.xml +++ b/cps/templates/osd.xml @@ -6,7 +6,7 @@ Janeczku https://github.com/janeczku/calibre-web + template="{{url_for('feed_cc_search')}}{searchTerms}"/> open diff --git a/cps/web.py b/cps/web.py index 1392d86c..36ab81a5 100644 --- a/cps/web.py +++ b/cps/web.py @@ -247,7 +247,7 @@ def load_user_from_header(header_val): header_val = header_val.replace('Basic ', '', 1) basic_username = basic_password = '' try: - header_val = base64.b64decode(header_val) + header_val = base64.b64decode(header_val).decode('utf-8') basic_username = header_val.split(':')[0] basic_password = header_val.split(':')[1] except TypeError: @@ -259,6 +259,8 @@ def load_user_from_header(header_val): def check_auth(username, password): + if sys.version_info.major == 3: + username=username.encode('windows-1252') user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == username.lower()).first() return bool(user and check_password_hash(user.password, password)) @@ -726,6 +728,7 @@ def feed_osd(): return render_xml_template('osd.xml', lang='en-EN') +@app.route("/opds/search/", defaults={'query': ""}) @app.route("/opds/search/") @requires_basic_auth_if_no_ano def feed_cc_search(query):