Ticket #393 (closed defect: fixed)

Opened 2 years ago

Last modified 18 months ago

WebOb Accept-Language prefix matching

Reported by: davisp Owned by: maluke
Priority: normal Milestone: 1.4.1
Component: webob Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

As near as I can tell, webob's accept-language matching isn't quite following the spec with respect to picking a quality when a prefix match is required.

From  http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4

'A language-range matches a language-tag if it exactly equals the tag, or if it exactly equals a prefix of the tag such that the first tag character following the prefix is "-".'

An example:

import webob
req = webob.Request.blank('/')

req.accept_language = 'en;q=0.5'
lang = req.accept_language.best_match(['en-gb'])
assert lang is 'en', "%r" % lang

And the assert fails with lang == None.

Though I could be completely misreading the spec.

Change History

Changed 2 years ago by maluke

I think you are correct about the spec. If you have a patch (preferably with tests) I'd apply it to the trunk.

Changed 18 months ago by maluke

  • owner changed from ianb to maluke

Changed 18 months ago by maluke

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.