diff --git a/digimarks.py b/digimarks.py index e03ed88..ceb6faa 100644 --- a/digimarks.py +++ b/digimarks.py @@ -582,6 +582,20 @@ def bookmarks_page(userkey, filtermethod=None, sortmethod=None): ) +@app.route('/r//') +def bookmark_redirect(userkey, urlhash): + """ Securely redirect a bookmark to its url, stripping referrer (if browser plays nice) """ + try: + bookmark = Bookmark.get( + Bookmark.url_hash == urlhash, + Bookmark.userkey == userkey, + Bookmark.status == Bookmark.VISIBLE + ) + except Bookmark.DoesNotExist: + abort(404) + return render_template('redirect.html', url=bookmark.url) + + @app.route('/api/v1/', methods=['GET', 'POST']) @app.route('/api/v1//filter/', methods=['GET', 'POST']) @app.route('/api/v1//sort/', methods=['GET', 'POST']) diff --git a/templates/redirect.html b/templates/redirect.html new file mode 100644 index 0000000..712fd31 --- /dev/null +++ b/templates/redirect.html @@ -0,0 +1,12 @@ + + + + Redirecting - digimarks + + + + + +

You're being redirected. If nothing happens, click here instead.

+ +