httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petr Lampa <la...@fee.vutbr.cz>
Subject [PATCH] mod_negotiation iso-8859-1 selected even if other acceptable
Date Mon, 24 Mar 1997 16:49:43 GMT

Yet another patch for mod_negotiation charset handling. This patch handles 
the situation, where some charset variant is available and acceptable, 
however the default iso-8859-1 variant is selected as it was 
found first. Consider the request:

GET /file HTTP/1.0
Accept-Charset: iso-8859-2

Suppose that we have two files, one in ISO-8859-2 and one in ISO-8859-1.
Quality of both is the same (charset quality of iso-8859-1 is always 1.0).
If the order of matching is:

/file.html1, charset=iso-8859-1, charset_quality = 1.0, q = 0.098
/file.html2, charset=iso-8859-2, charset_quality = 1.0, q = 0.098

then iso-8859-1 is selected, although iso-8859-2 variant is available. 

Proposed solution:

If charset quality of current variant and best variant is equal 
and the best variant is in ISO-8859-1, then prefer current variant:

is_variant_better():
...
!     if (variant->charset_quality > best->charset_quality) {
          *p_bestq = q;
          return 1;
      }
--- 1532,1543 ----
!     /* If the best variant's charset is ISO-8859-1 and this variant has
!        the same charset quality, then we prefer this variant */
!     if (variant->charset_quality > best->charset_quality ||
!         (variant->charset_quality == best->charset_quality &&
!         (best->content_charset == NULL || *best->content_charset == 0 ||
!         strcmp(best->content_charset, "iso-8859-1") == 0))) {
          *p_bestq = q;
          return 1;
      }

Full patch is attached.

							Petr Lampa

-- 
Department of Computer Science and Engineering  E-mail: lampa@fee.vutbr.cz
Faculty of El. Engineering and Comp. Science	Phone: (+420 5) 7275/225,111
Technical University of Brno			Fax:  (+420 5) 41211141
Bozetechova 2, 612 66 Brno, Czech Republic

Mime
View raw message