]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
The web interface did not support newer language identifiers used by Microsoft
authorMichael Sweet <michael.r.sweet@gmail.com>
Mon, 28 Aug 2017 20:18:18 +0000 (16:18 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Mon, 28 Aug 2017 20:18:18 +0000 (16:18 -0400)
web browsers (Issue #5803)

Make sure cupsLangGet supports region codes and that the scheduler uses
cupsLangGet when mapping IPP naturalLanguage values to POSIX locales.

CHANGES.md
cups/language.c
scheduler/client.c

index 7a707362be9ae098c1859501e8d29335796aee4b..28965b441e345d80108e7669f5212fbc20177147 100644 (file)
@@ -26,6 +26,8 @@ CHANGES IN CUPS V2.2.5
   values (Issue #5074)
 - The scheduler now creates a PID file when not running on demand with a modern
   service launcher (Issue #5080)
+- The web interface did not support newer language identifiers used by Microsoft
+  web browsers (Issue #5803)
 - Updated the cups-files.conf and cupsd.conf file documentation for missing
   directives (Issue #5084)
 - Fixed an Avahi-related crash bug in the scheduler (Issue #5085, Issue #5086)
index 626c1316a11293f528373447339eb0a3fc50af1a..289f7b41886183506085fbee06f3ea8cf132646a 100644 (file)
@@ -692,6 +692,15 @@ cupsLangGet(const char *language)  /* I - Language or locale */
           *ptr++ = (char)toupper(*language & 255);
 
       *ptr = '\0';
+
+     /*
+      * Map Chinese region codes to legacy country codes.
+      */
+
+      if (!strcmp(country, "HANS"))
+        strlcpy(country, "CN", sizeof(country));
+      if (!strcmp(country, "HANT"))
+        strlcpy(country, "TW", sizeof(country));
     }
 
     if (*language == '.' && !charset[0])
index f27decda47390b60982354388d4fe70c4730f4a0..78695ae659957f53ea1e860e8cd14e231792f8e2 100644 (file)
@@ -3627,42 +3627,12 @@ pipe_command(cupsd_client_t *con,       /* I - Client connection */
   else
     auth_type[0] = '\0';
 
-  if (con->request &&
-      (attr = ippFindAttribute(con->request, "attributes-natural-language",
-                               IPP_TAG_LANGUAGE)) != NULL)
+  if (con->request && (attr = ippFindAttribute(con->request, "attributes-natural-language", IPP_TAG_LANGUAGE)) != NULL)
   {
-    switch (strlen(attr->values[0].string.text))
-    {
-      default :
-        /*
-         * This is an unknown or badly formatted language code; use
-         * the POSIX locale...
-         */
-
-         strlcpy(lang, "LANG=C", sizeof(lang));
-         break;
-
-      case 2 :
-        /*
-         * Just the language code (ll)...
-         */
+    cups_lang_t *language = cupsLangGet(ippGetString(attr, 0, NULL));
 
-         snprintf(lang, sizeof(lang), "LANG=%s.UTF8",
-                  attr->values[0].string.text);
-         break;
-
-      case 5 :
-        /*
-         * Language and country code (ll-cc)...
-         */
-
-         snprintf(lang, sizeof(lang), "LANG=%c%c_%c%c.UTF8",
-                  attr->values[0].string.text[0],
-                  attr->values[0].string.text[1],
-                  toupper(attr->values[0].string.text[3] & 255),
-                  toupper(attr->values[0].string.text[4] & 255));
-         break;
-    }
+    snprintf(lang, sizeof(lang), "LANG=%s.UTF8", language->language);
+    cupsLangFree(language);
   }
   else if (con->language)
     snprintf(lang, sizeof(lang), "LANG=%s.UTF8", con->language->language);