summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Havard <bjh@apache.org>2000-08-06 15:07:41 +0000
committerBrian Havard <bjh@apache.org>2000-08-06 15:07:41 +0000
commit4535bf853d2cb3baa63cbec89cc0f3a3ced51fb2 (patch)
tree16ab24c8d22e873eff7a94fb898f4ff6fd5b470f
parentaed89bc6b4d496574ff51b1e67b94baa942137fc (diff)
downloadhttpd-4535bf853d2cb3baa63cbec89cc0f3a3ced51fb2.tar.gz
Some enhancements for OS/2 ap_canonical_filename:
- Log proper error message instead of error code on failure - In case of error caused by an invalid file name, don't return an empty string as that tends to confuse things rather than make them better. - Avoid using the very expensive ap_os_systemcase_canonical_filename() unless it's truely necessary. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86011 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--os/os2/util_os2.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/os/os2/util_os2.c b/os/os2/util_os2.c
index 3fbae4bf66..180bf7c69e 100644
--- a/os/os2/util_os2.c
+++ b/os/os2/util_os2.c
@@ -86,12 +86,10 @@ API_EXPORT(char *)ap_os_case_canonical_filename(apr_pool_t *pPool, const char *s
rc = DosQueryPathInfo(buf, FIL_QUERYFULLNAME, buf2, HUGE_STRING_LEN);
if (rc) {
- if ( rc != ERROR_INVALID_NAME ) {
- ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL, "OS/2 error %d for file %s", rc, szFile);
- return apr_pstrdup(pPool, "");
- } else {
- return apr_pstrdup(pPool, szFile);
+ if (rc != ERROR_INVALID_NAME) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_OS2_STATUS(rc), NULL, "for file [%s]", szFile);
}
+ apr_cpystrn(buf2, buf, sizeof(buf2));
}
/* Switch backslashes to forward */
@@ -151,7 +149,24 @@ char *ap_os_systemcase_canonical_filename(apr_pool_t *pPool, const char *szFile)
char *ap_os_canonical_filename(apr_pool_t *pPool, const char *szFile)
{
- char *szCanonicalFile = ap_os_systemcase_canonical_filename(pPool, szFile);
+ char *szCanonicalFile;
+ const unsigned char *pos = szFile;
+
+ /* Find any 8 bit characters */
+ while (*pos && *pos < 128) {
+ pos++;
+ }
+
+ /* Only use the very expensive ap_os_systemcase_canonical_filename() if
+ * the file name contains non-english characters as they are the only type
+ * that can't be made canonical with a simple strlwr()
+ */
+ if (*pos < 128) {
+ szCanonicalFile = ap_os_case_canonical_filename(pPool, szFile);
+ } else {
+ szCanonicalFile = ap_os_systemcase_canonical_filename(pPool, szFile);
+ }
+
strlwr(szCanonicalFile);
return szCanonicalFile;
}