comparison src/server/pages.py @ 1061:bacb8f229742

pages: fixed unicode escaping when using a redirecting URL
author Goffi <goffi@goffi.org>
date Sun, 11 Mar 2018 19:28:10 +0100
parents f0f7b3324749
children c80649cdadd5
comparison
equal deleted inserted replaced
1060:f0f7b3324749 1061:bacb8f229742
776 """redirect to an URL using HTTP redirection 776 """redirect to an URL using HTTP redirection
777 777
778 @param request(server.Request): current HTTP request 778 @param request(server.Request): current HTTP request
779 @param url(unicode): url to redirect to 779 @param url(unicode): url to redirect to
780 """ 780 """
781
782 web_util.redirectTo(url.encode('utf-8'), request) 781 web_util.redirectTo(url.encode('utf-8'), request)
783 request.finish() 782 request.finish()
784 raise failure.Failure(exceptions.CancelError(u'HTTP redirection is used')) 783 raise failure.Failure(exceptions.CancelError(u'HTTP redirection is used'))
785 784
786 def redirectOrContinue(self, request, redirect_arg=u'redirect_url'): 785 def redirectOrContinue(self, request, redirect_arg=u'redirect_url'):
791 @param redirect_arg(unicode): argument to use to get redirection URL 790 @param redirect_arg(unicode): argument to use to get redirection URL
792 @interrupt: redirect the page to requested URL 791 @interrupt: redirect the page to requested URL
793 @interrupt pageError(C.HTTP_BAD_REQUEST): empty or non local URL is used 792 @interrupt pageError(C.HTTP_BAD_REQUEST): empty or non local URL is used
794 """ 793 """
795 try: 794 try:
796 url = self.getPostedData(request, 'redirect_url') 795 url = request.args['redirect_url'][0]
797 except KeyError: 796 except (KeyError, IndexError):
798 pass 797 pass
799 else: 798 else:
800 # a redirection is requested 799 # a redirection is requested
801 if not url or url[0] != u'/': 800 if not url or url[0] != u'/':
802 # we only want local urls 801 # we only want local urls
1020 @param multiple(bool): True if multiple values are possible/expected 1019 @param multiple(bool): True if multiple values are possible/expected
1021 if False, the first value is returned 1020 if False, the first value is returned
1022 @return (iterator[unicode], list[iterator[unicode], unicode, list[unicode]): values received for this(these) key(s) 1021 @return (iterator[unicode], list[iterator[unicode], unicode, list[unicode]): values received for this(these) key(s)
1023 @raise KeyError: one specific key has been requested, and it is missing 1022 @raise KeyError: one specific key has been requested, and it is missing
1024 """ 1023 """
1024 # FIXME: request.args is already unquoting the value, it seems we are doing double unquote
1025 if isinstance(keys, basestring): 1025 if isinstance(keys, basestring):
1026 keys = [keys] 1026 keys = [keys]
1027 get_first = True 1027 get_first = True
1028 else: 1028 else:
1029 get_first = False 1029 get_first = False