From f3e22caf1ad0b81a0a11fd1e8c63dcf64e380fe1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Malo?= Date: Sun, 25 Jan 2004 15:40:08 +0000 Subject: [PATCH] EOLs sent by external rewritemaps are now consumed as whole. That way, on systems with more than one EOL character rewritemap programs no longer need to switch stdout to binary mode. PR: 25635 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102404 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ modules/mappers/mod_rewrite.c | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 3ff4d8cf2a..3447530b15 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) mod_rewrite: EOLs sent by external rewritemaps are now consumed + as whole. That way, on systems with more than one EOL character + rewritemap programs no longer need to switch stdout to binary + mode. PR 25635. [André Malo] + *) mod_rewrite: Introduce the ability to force a content handler via the [handler=...] flag. [André Malo] diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index cfde1b4627..94cdb5bde8 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -1348,6 +1348,8 @@ static char *lookup_map_program(request_rec *r, apr_file_t *fpin, apr_size_t i; apr_size_t nbytes; apr_status_t rv; + const char *eol = APR_EOL_STR; + int eolc = 0; #ifndef NO_WRITEV struct iovec iova[2]; @@ -1400,11 +1402,25 @@ static char *lookup_map_program(request_rec *r, apr_file_t *fpin, nbytes = 1; apr_file_read(fpout, &c, &nbytes); while (nbytes == 1 && (i < REWRITE_MAX_PRG_MAP_LINE)) { - if (c == '\n') { + if (c == eol[eolc]) { + if (!eol[++eolc]) { + /* remove eol from the buffer */ + i -= --eolc; + break; + } + } + + /* only partial (invalid) eol sequence -> reset the counter */ + else if (eolc) { + eolc = 0; + } + + /* catch binary mode, e.g. on Win32 */ + else if (c == '\n') { break; } - buf[i++] = c; + buf[i++] = c; apr_file_read(fpout, &c, &nbytes); } -- 2.40.0