]> granicus.if.org Git - apache/commitdiff
EOLs sent by external rewritemaps are now consumed
authorAndré Malo <nd@apache.org>
Sun, 25 Jan 2004 15:40:08 +0000 (15:40 +0000)
committerAndré Malo <nd@apache.org>
Sun, 25 Jan 2004 15:40:08 +0000 (15:40 +0000)
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
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 3ff4d8cf2a2d4899f0ae848173ff6b316cf3eb9a..3447530b152e9e139304ed52c317dcff7edbe517 100644 (file)
--- 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]
 
index cfde1b462706428b975ece096bcb8f8c2c3977c1..94cdb5bde80056d3f4900574a2db1fa7974f3361 100644 (file)
@@ -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);
     }