summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--modules/mappers/mod_rewrite.c20
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);
}