From d01a6bbf2065eadb9f4d9a74a8118e37bee38035 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Sun, 11 Sep 2005 20:28:20 +0000 Subject: [PATCH] Backport 280114 rewrite CR mitigation logic to wipe out any trailing white space Submitted by: trawick Suggested and reviewed by: wrowe git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@280177 13f79535-47bb-0310-9956-ffa450edef68 --- modules/metadata/mod_mime_magic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c index f4ca7207b2a..d0f485fac19 100644 --- a/modules/metadata/mod_mime_magic.c +++ b/modules/metadata/mod_mime_magic.c @@ -947,16 +947,16 @@ static int apprentice(server_rec *s, apr_pool_t *p) /* parse it */ for (lineno = 1; apr_file_gets(line, BUFSIZ, f) == APR_SUCCESS; lineno++) { int ws_offset; - char *last = line + strlen(line) - 1; /* guaranteed that len >= 1 */ + char *last = line + strlen(line) - 1; /* guaranteed that len >= 1 since an + * "empty" line contains a '\n' + */ - /* delete newline and potential carriage return */ - if (*last == '\n') { + /* delete newline and any other trailing whitespace */ + while (last >= line + && apr_isspace(*last)) { *last = '\0'; --last; } - if (*last == '\r') { - *last = '\0'; - } /* skip leading whitespace */ ws_offset = 0; -- 2.47.2