home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / linux / apache / contrib / patches / 1.2 / conneg-bug.patch < prev    next >
Encoding:
Text File  |  1998-06-11  |  4.0 KB  |  91 lines

  1. Title: Content Negotiation bug fix for Apache 1.2
  2. Submitter: Paul Sutton <pcs@apache.org>
  3.  
  4. Content Negotiation no longer picks the smallest equally
  5. acceptable variant unless all variants have character sets.
  6. Also it now picks the last equally acceptable variant instead
  7. of the first.
  8.  
  9. Detailed explaination:
  10.  
  11. The problem is that if you have multiple variants that are otherwise
  12. equal, Apache prefers the _last_ listed variant in the type map (or the
  13. last file read from the file system). This contradicts all the other tests
  14. - and the documented algorythm - which prefer the first variant out of
  15. equally acceptable ones. The bug was introduced in a patch to prefer
  16. non-iso-8859-1 charsets, but is has the side-effect of always picking the
  17. last equally acceptable variant. The equal variants might all have no
  18. charset at all or all by iso-8859-1. The effect when no variants have
  19. charsets is particularly unwelcome, and causes the #94 bug. This bug has
  20. the effect of never allowing the final test for file size to be applied. 
  21.  
  22. PR#94 has a jpg and gif (listed in that order), and under Apache prior to
  23. 1.2b7, the jpg would have been chosen because of its smaller filesize.
  24. Currently the gif is chosen, because it is listed last and because it has
  25. no charset (if all variant are given charsets and none of the charsets are
  26. iso-8859-1 the negotiation works ok). But many file types, such as images,
  27. do not have character sets.
  28.  
  29. The patch below attempts to fix the problem. It only picks a later-listed
  30. variant as the best match if
  31.  
  32.     The charset qualities of both variant and best-match-so-far are equal
  33. AND the current variant has a charset which is not iso-8859-1
  34. AND (the previous best match had a no charset OR a charset of iso-8859-1)
  35.  
  36. This now prefers the _first_ variant with matching charsets, or if no
  37. charsets are present allows a fall-through to the file-size checking code. 
  38.  
  39. Patch:
  40.  
  41. *** mod_negotiation.c.dist    Fri May 30 16:04:35 1997
  42. --- mod_negotiation.c    Fri May 30 17:05:28 1997
  43. ***************
  44. *** 1439,1446 ****
  45.           /* If the best variant's charset is ISO-8859-1 and this variant has
  46.              the same charset quality, then we prefer this variant */
  47.           if (variant->charset_quality == best->charset_quality &&
  48. !             (best->content_charset == NULL || *best->content_charset == 0 ||
  49. !             strcmp(best->content_charset, "iso-8859-1") == 0)) {
  50.               *p_bestq = q;
  51.               return 1;
  52.       }
  53. --- 1439,1449 ----
  54.           /* If the best variant's charset is ISO-8859-1 and this variant has
  55.              the same charset quality, then we prefer this variant */
  56.           if (variant->charset_quality == best->charset_quality &&
  57. !             (variant->content_charset != NULL &&
  58. !              strcmp(variant->content_charset, "iso-8859-1") != 0) &&
  59. !             (best->content_charset == NULL ||
  60. !              *best->content_charset == '\0' ||
  61. !              strcmp(best->content_charset, "iso-8859-1") == 0)) {
  62.               *p_bestq = q;
  63.               return 1;
  64.       }
  65. ***************
  66. *** 1538,1546 ****
  67.       /* If the best variant's charset is ISO-8859-1 and this variant has
  68.          the same charset quality, then we prefer this variant */
  69.       if (variant->charset_quality > best->charset_quality ||
  70. !         (variant->charset_quality == best->charset_quality &&
  71. !         (best->content_charset == NULL || *best->content_charset == 0 ||
  72. !         strcmp(best->content_charset, "iso-8859-1") == 0))) {
  73.           *p_bestq = q;
  74.           return 1;
  75.       }
  76. --- 1541,1551 ----
  77.       /* If the best variant's charset is ISO-8859-1 and this variant has
  78.          the same charset quality, then we prefer this variant */
  79.       if (variant->charset_quality > best->charset_quality ||
  80. !         (variant->content_charset != NULL &&
  81. !          strcmp(variant->content_charset, "iso-8859-1") != 0) &&
  82. !         (best->content_charset == NULL ||
  83. !          *best->content_charset == '\0' ||
  84. !          strcmp(best->content_charset, "iso-8859-1") == 0)) {
  85.           *p_bestq = q;
  86.           return 1;
  87.       }
  88.  
  89.  
  90.  
  91.