From 4603595e1c07d0ad659f020bbd5071e48c955d91 Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Thu, 15 Feb 2018 17:42:14 +0000 Subject: [PATCH] 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 --- CHANGES | 3 +++ modules/aaa/mod_authnz_ldap.c | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 91c3208426..b85a7520dc 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 893cd1d9d7..b9f8671c75 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) { -- 2.40.0