home *** CD-ROM | disk | FTP | other *** search
- Title: Content Negotiation bug fix for Apache 1.2
- Submitter: Paul Sutton <pcs@apache.org>
-
- Content Negotiation no longer picks the smallest equally
- acceptable variant unless all variants have character sets.
- Also it now picks the last equally acceptable variant instead
- of the first.
-
- Detailed explaination:
-
- The problem is that if you have multiple variants that are otherwise
- equal, Apache prefers the _last_ listed variant in the type map (or the
- last file read from the file system). This contradicts all the other tests
- - and the documented algorythm - which prefer the first variant out of
- equally acceptable ones. The bug was introduced in a patch to prefer
- non-iso-8859-1 charsets, but is has the side-effect of always picking the
- last equally acceptable variant. The equal variants might all have no
- charset at all or all by iso-8859-1. The effect when no variants have
- charsets is particularly unwelcome, and causes the #94 bug. This bug has
- the effect of never allowing the final test for file size to be applied.
-
- PR#94 has a jpg and gif (listed in that order), and under Apache prior to
- 1.2b7, the jpg would have been chosen because of its smaller filesize.
- Currently the gif is chosen, because it is listed last and because it has
- no charset (if all variant are given charsets and none of the charsets are
- iso-8859-1 the negotiation works ok). But many file types, such as images,
- do not have character sets.
-
- The patch below attempts to fix the problem. It only picks a later-listed
- variant as the best match if
-
- The charset qualities of both variant and best-match-so-far are equal
- AND the current variant has a charset which is not iso-8859-1
- AND (the previous best match had a no charset OR a charset of iso-8859-1)
-
- This now prefers the _first_ variant with matching charsets, or if no
- charsets are present allows a fall-through to the file-size checking code.
-
- Patch:
-
- *** mod_negotiation.c.dist Fri May 30 16:04:35 1997
- --- mod_negotiation.c Fri May 30 17:05:28 1997
- ***************
- *** 1439,1446 ****
- /* 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 &&
- ! (best->content_charset == NULL || *best->content_charset == 0 ||
- ! strcmp(best->content_charset, "iso-8859-1") == 0)) {
- *p_bestq = q;
- return 1;
- }
- --- 1439,1449 ----
- /* 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->content_charset != NULL &&
- ! strcmp(variant->content_charset, "iso-8859-1") != 0) &&
- ! (best->content_charset == NULL ||
- ! *best->content_charset == '\0' ||
- ! strcmp(best->content_charset, "iso-8859-1") == 0)) {
- *p_bestq = q;
- return 1;
- }
- ***************
- *** 1538,1546 ****
- /* 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;
- }
- --- 1541,1551 ----
- /* 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->content_charset != NULL &&
- ! strcmp(variant->content_charset, "iso-8859-1") != 0) &&
- ! (best->content_charset == NULL ||
- ! *best->content_charset == '\0' ||
- ! strcmp(best->content_charset, "iso-8859-1") == 0)) {
- *p_bestq = q;
- return 1;
- }
-
-
-
-