From: Michael Sweet Date: Mon, 28 Aug 2017 20:18:18 +0000 (-0400) Subject: The web interface did not support newer language identifiers used by Microsoft X-Git-Tag: v2.2.5~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2793a478d0904d31ea4aff2db90b8026d4c67ff9;p=thirdparty%2Fcups.git The web interface did not support newer language identifiers used by Microsoft web browsers (Issue #5803) Make sure cupsLangGet supports region codes and that the scheduler uses cupsLangGet when mapping IPP naturalLanguage values to POSIX locales. --- diff --git a/CHANGES.md b/CHANGES.md index 7a707362be..28965b441e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/cups/language.c b/cups/language.c index 626c1316a1..289f7b4188 100644 --- a/cups/language.c +++ b/cups/language.c @@ -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]) diff --git a/scheduler/client.c b/scheduler/client.c index f27decda47..78695ae659 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -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);