You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by "James A. Treacy" <tr...@debian.org> on 1998/11/04 23:30:00 UTC
Re: mod_negotiation/3299: random language variant returned when no Accept-Language: header is given
The following reply was made to PR mod_negotiation/3299; it has been noted by GNATS.
From: "James A. Treacy" <tr...@debian.org>
To: lars@apache.org
Cc: apbugs@Apache.Org
Subject: Re: mod_negotiation/3299: random language variant returned when no Accept-Language: header is given
Date: Wed, 4 Nov 1998 17:29:15 -0500
On Thu, Oct 29, 1998 at 04:33:24AM -0000, lars@apache.org wrote:
>
> Synopsis: random language variant returned when no Accept-Language: header is given
>
> I'm not able to reproduce your problem.
> Are you using any third-party modules?
>
The problem has been found. A patch and explanation follow.
Subroutine is_variant_better in mod_negotiation.c states that if the
languages are equal to try the LanguagePriority. Fair enough. But if
best->lang_index != -1 and variant->lang_index == -1 it believes the
variant is better than the current best so it doesn't return 0 when it
should. It then recognizes in the next 'if' statement that the variant
is not better so continues until it uses the length of the files to
decide which is better.
The fix is to simply check for variant->lang_index == -1
With the correction the only condition that lets you fall through this
section is if best->lang_index == variant->lang_index == -1
This implies that neither is in LanguagePriority.
As noted in the original message, this only affects requests for which
there is no Accept-Language: header sent.
Jay Treacy
*** mod_negotiation.c Wed Nov 4 16:53:29 1998
--- mod_negotiation.c.orig Tue Nov 3 11:53:28 1998
***************
*** 1645,1651 ****
/* if language qualities were equal, try the LanguagePriority
* stuff */
! if (best->lang_index != -1 && (variant->lang_index == -1 || variant->lang_index > best->lang_index)) {
return 0;
}
if (variant->lang_index != -1 &&
--- 1645,1651 ----
/* if language qualities were equal, try the LanguagePriority
* stuff */
! if (best->lang_index != -1 && variant->lang_index > best->lang_index) {
return 0;
}
if (variant->lang_index != -1 &&