#5076: Request object should try to determine encoding
-------------------------------------+-------------------------------------
     Reporter:  dbr <daniel@…>       |                    Owner:
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  master
    Component:  HTTP handling        |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  unicode conversion   |      Needs documentation:  0
  charset POST request               |  Patch needs improvement:  1
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by aaugustin):

 The patch for #19101 includes the fix for this ticket. However, I'd prefer
 to fix these issues separately, so I'm going to comment here.

 I'd like to see a more robust
 [http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 media type]
 parsing. The grammar is simple enough to implement correctly. For example:

 {{{
 content_type = self.META.get('CONTENT_TYPE', '')
 content_type, _, parameters = content_type.partition(';')
 content_params = {}
 for parameter in parameters.split(';'):
     k, _, v = parameter.strip().partition('=')
     content_params[k] = v
 }}}

 It could make sense to move this to a utility function or at least as a
 method of the HttpRequest object, as in the patches above.

 Then we just do:
 {{{
 if 'charset' in content_params:
     ...
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/5076#comment:12>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to