#32837: Flatpages manipulates url before get_object_or_404 leads to error
-----------------------------------------+------------------------
               Reporter:  snake-soft     |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  3.1
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Django flatpages has some unwanted behaviour can lead to a catched
 exception that is not easy to resolve.
 This problem occurs when saving a FlatPage object without a leading slash
 in the url.

 The view is located in:
  django.contrib.flatpages.views

 This is the problematic flatpage view:
 {{{
 def flatpage(request, url):
     if not url.startswith('/'):
         url = '/' + url
     site_id = get_current_site(request).id
     try:
         f = get_object_or_404(FlatPage, url=url, sites=site_id)
     except Http404:
         if not url.endswith('/') and settings.APPEND_SLASH:
             url += '/'
             f = get_object_or_404(FlatPage, url=url, sites=site_id)
             return HttpResponsePermanentRedirect('%s/' % request.path)
         else:
             raise
     return render_flatpage(request, f)
 }}}


 I think it doesn't make sense to manipulate the url at this point because
 nothing happens with the url between manipulating an fetching the FlatPage
 from db.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32837>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.a3d277ad53af9586488a4bdf752b077b%40djangoproject.com.

Reply via email to