]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_authnz_ldap: Fix language long names detection as short name.
authorYann Ylavic <ylavic@apache.org>
Thu, 15 Feb 2018 17:42:14 +0000 (17:42 +0000)
committerYann Ylavic <ylavic@apache.org>
Thu, 15 Feb 2018 17:42:14 +0000 (17:42 +0000)
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
modules/aaa/mod_authnz_ldap.c

diff --git a/CHANGES b/CHANGES
index 91c3208426c4b88d52e96f0990763d0dfb296fd1..b85a7520dc61a34e332ca02234824691b854886c 100644 (file)
--- 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]
 
index 893cd1d9d78d9e9d9ac31b4caea1ad94d6bd7cf9..b9f8671c756b235a9932cfa85e577e1289d6fcc2 100644 (file)
@@ -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) {