11# Copyright The IETF Trust 2007-2019, All Rights Reserved
2-
2+ # -*- coding: utf-8 -*-
3+ #
34# Portions Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
45# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
56#
3233# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3334# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3435
36+
37+ from __future__ import absolute_import , print_function , unicode_literals
38+
3539import importlib
3640
3741from datetime import datetime as DateTime , timedelta as TimeDelta , date as Date
5458from django .utils .safestring import mark_safe
5559from django .http import Http404 , HttpResponseRedirect #, HttpResponse,
5660from django .shortcuts import render , redirect , get_object_or_404
61+ from django .utils .encoding import force_bytes
5762
5863import debug # pyflakes:ignore
5964
@@ -674,7 +679,7 @@ def apikey_disable(request):
674679 class KeyDeleteForm (forms .Form ):
675680 hash = forms .ChoiceField (label = 'Key' , choices = choices )
676681 def clean_key (self ):
677- hash = self .cleaned_data ['hash' ]
682+ hash = force_bytes ( self .cleaned_data ['hash' ])
678683 key = PersonalApiKey .validate_key (hash )
679684 if key and key .person == request .user .person :
680685 return hash
@@ -684,7 +689,7 @@ def clean_key(self):
684689 if request .method == 'POST' :
685690 form = KeyDeleteForm (request .POST )
686691 if form .is_valid ():
687- hash = form .data ['hash' ]
692+ hash = force_bytes ( form .data ['hash' ])
688693 key = PersonalApiKey .validate_key (hash )
689694 key .valid = False
690695 key .save ()
0 commit comments