Index: client.c =================================================================== --- client.c (revision 6793) +++ client.c (working copy) @@ -3228,12 +3228,15 @@ int status; /* Status of filesystem calls */ char *ptr; /* Pointer info filename */ int plen; /* Remaining length after pointer */ + char language[7]; /* Language subdirectory, if any */ /* * Figure out the real filename... */ + language[0] = '\0'; + if (!strncmp(con->uri, "/ppd/", 5)) snprintf(filename, len, "%s%s", ServerRoot, con->uri); else if (!strncmp(con->uri, "/rss/", 5) && !strchr(con->uri + 5, '/')) @@ -3252,8 +3255,10 @@ return (NULL); } else if (con->language) - snprintf(filename, len, "%s/%s%s", DocumentRoot, con->language->language, - con->uri); + { + snprintf(language, sizeof(language), "/%s", con->language->language); + snprintf(filename, len, "%s%s%s", DocumentRoot, language, con->uri); + } else snprintf(filename, len, "%s%s", DocumentRoot, con->uri); @@ -3265,7 +3270,7 @@ * then fallback to the default one... */ - if ((status = stat(filename, filestats)) != 0 && con->language && + if ((status = stat(filename, filestats)) != 0 && language[0] && strncmp(con->uri, "/ppd/", 5) && strncmp(con->uri, "/admin/conf/", 12) && strncmp(con->uri, "/admin/log/", 11)) @@ -3274,12 +3279,9 @@ * Drop the country code... */ - char ll[3]; /* Short language name */ + language[3] = '\0'; + snprintf(filename, len, "%s%s%s", DocumentRoot, language, con->uri); - - strlcpy(ll, con->language->language, sizeof(ll)); - snprintf(filename, len, "%s/%s%s", DocumentRoot, ll, con->uri); - if ((ptr = strchr(filename, '?')) != NULL) *ptr = '\0'; @@ -3289,6 +3291,7 @@ * Drop the language prefix and try the root directory... */ + language[0] = '\0'; snprintf(filename, len, "%s%s", DocumentRoot, con->uri); if ((ptr = strchr(filename, '?')) != NULL) @@ -3304,52 +3307,86 @@ if (!status && S_ISDIR(filestats->st_mode)) { - if (filename[strlen(filename) - 1] != '/') - strlcat(filename, "/", len); + /* + * Make sure the URI ends with a slash... + */ - ptr = filename + strlen(filename); - plen = len - (ptr - filename); + if (con->uri[strlen(con->uri) - 1] != '/') + strlcat(con->uri, "/", sizeof(con->uri)); - strlcpy(ptr, "index.html", plen); - status = stat(filename, filestats); + /* + * Find the directory index file, trying every language... + */ -#ifdef HAVE_JAVA - if (status) + do { - strlcpy(ptr, "index.class", plen); + if (status && language[0]) + { + /* + * Try a different language subset... + */ + + if (language[3]) + language[0] = '\0'; /* Strip country code */ + else + language[0] = '\0'; /* Strip language */ + } + + /* + * Look for the index file... + */ + + snprintf(filename, len, "%s%s%s", DocumentRoot, language, con->uri); + + if ((ptr = strchr(filename, '?')) != NULL) + *ptr = '\0'; + + ptr = filename + strlen(filename); + plen = len - (ptr - filename); + + strlcpy(ptr, "index.html", plen); status = stat(filename, filestats); - } + +#ifdef HAVE_JAVA + if (status) + { + strlcpy(ptr, "index.class", plen); + status = stat(filename, filestats); + } #endif /* HAVE_JAVA */ #ifdef HAVE_PERL - if (status) - { - strlcpy(ptr, "index.pl", plen); - status = stat(filename, filestats); - } + if (status) + { + strlcpy(ptr, "index.pl", plen); + status = stat(filename, filestats); + } #endif /* HAVE_PERL */ #ifdef HAVE_PHP - if (status) - { - strlcpy(ptr, "index.php", plen); - status = stat(filename, filestats); - } + if (status) + { + strlcpy(ptr, "index.php", plen); + status = stat(filename, filestats); + } #endif /* HAVE_PHP */ #ifdef HAVE_PYTHON - if (status) - { - strlcpy(ptr, "index.pyc", plen); - status = stat(filename, filestats); - } + if (status) + { + strlcpy(ptr, "index.pyc", plen); + status = stat(filename, filestats); + } - if (status) - { - strlcpy(ptr, "index.py", plen); - status = stat(filename, filestats); + if (status) + { + strlcpy(ptr, "index.py", plen); + status = stat(filename, filestats); + } +#endif /* HAVE_PYTHON */ + } -#endif /* HAVE_PYTHON */ + while (status && language[0]); } cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_file: %d filename=%s size=%d",