mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.6.x] Fixed #10491 -- Allowed passing lazy objects to HttpResponseRedirect.
Thanks liangent for the report.
Backport of 3c45fb8589 from master
			
			
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							bf132bcb8d
						
					
				
				
					commit
					badca4716f
				
			| @@ -15,7 +15,7 @@ from django.core import signing | ||||
| from django.core.exceptions import DisallowedRedirect | ||||
| from django.http.cookie import SimpleCookie | ||||
| from django.utils import six, timezone | ||||
| from django.utils.encoding import force_bytes, iri_to_uri | ||||
| from django.utils.encoding import force_bytes, force_text, iri_to_uri | ||||
| from django.utils.http import cookie_date | ||||
| from django.utils.six.moves import map | ||||
|  | ||||
| @@ -454,7 +454,7 @@ class HttpResponseRedirectBase(HttpResponse): | ||||
|     allowed_schemes = ['http', 'https', 'ftp'] | ||||
|  | ||||
|     def __init__(self, redirect_to, *args, **kwargs): | ||||
|         parsed = urlparse(redirect_to) | ||||
|         parsed = urlparse(force_text(redirect_to)) | ||||
|         if parsed.scheme and parsed.scheme not in self.allowed_schemes: | ||||
|             raise DisallowedRedirect("Unsafe redirect to URL with protocol '%s'" % parsed.scheme) | ||||
|         super(HttpResponseRedirectBase, self).__init__(*args, **kwargs) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user