From: Yann Ylavic Date: Thu, 15 Feb 2018 17:42:14 +0000 (+0000) Subject: mod_authnz_ldap: Fix language long names detection as short name. X-Git-Tag: 2.5.0-alpha2-ci-test-only~2862 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4603595e1c07d0ad659f020bbd5071e48c955d91;p=thirdparty%2Fapache%2Fhttpd.git mod_authnz_ldap: Fix language long names detection as short name. Make sure the long name format is relevent before converting it. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1824336 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 91c3208426c..b85a7520dc6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.1 + *) mod_authnz_ldap: Fix language long names detection as short name. + [Yann Ylavic] + *) core: For consistency, ensure that read lines are NUL terminated on any error, not only on buffer full. [Yann Ylavic] diff --git a/modules/aaa/mod_authnz_ldap.c b/modules/aaa/mod_authnz_ldap.c index 893cd1d9d78..b9f8671c756 100644 --- a/modules/aaa/mod_authnz_ldap.c +++ b/modules/aaa/mod_authnz_ldap.c @@ -126,9 +126,13 @@ static char* derive_codepage_from_lang (apr_pool_t *p, char *language) charset = (char*) apr_hash_get(charset_conversions, language, APR_HASH_KEY_STRING); - if (!charset) { - language[2] = '\0'; - charset = (char*) apr_hash_get(charset_conversions, language, APR_HASH_KEY_STRING); + /* + * Test if language values like 'en-US' return a match from the charset + * conversion map when shortened to 'en'. + */ + if (!charset && strlen(language) > 3 && language[2] == '-') { + char *language_short = apr_pstrndup(p, language, 2); + charset = (char*) apr_hash_get(charset_conversions, language_short, APR_HASH_KEY_STRING); } if (charset) {