trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] 01/02: TS-4930: Unfolds request headers that are using obs continuations
Date Fri, 21 Apr 2017 00:59:07 GMT
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit da4a9f6ed21fb0f0694a9bc1e0ae4a616d23f610
Author: Leif Hedstrom <zwoop@apache.org>
AuthorDate: Tue Oct 4 11:22:05 2016 -0600

    TS-4930: Unfolds request headers that are using obs continuations
---
 proxy/hdrs/HdrTest.cc | 26 ++++++++++++++++++++++++--
 proxy/hdrs/MIME.cc    |  6 ++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/proxy/hdrs/HdrTest.cc b/proxy/hdrs/HdrTest.cc
index f962925..e69f37a 100644
--- a/proxy/hdrs/HdrTest.cc
+++ b/proxy/hdrs/HdrTest.cc
@@ -475,7 +475,9 @@ HdrTest::test_url()
 int
 HdrTest::test_mime()
 {
-  static const char mime[] = {
+  // This can not be a static string (any more) since we unfold the headers
+  // in place.
+  char mime[] = {
     //        "Date: Tuesday, 08-Dec-98 20:32:17 GMT\r\n"
     "Date: 6 Nov 1994 08:49:37 GMT\r\n"
     "Max-Forwards: 65535\r\n"
@@ -523,6 +525,26 @@ HdrTest::test_mime()
     return (failures_to_status("test_mime", 1));
   }
 
+  // Test the (new) continuation line folding to be correct. This should replace the
+  // \r\n with two spaces (so a total of three between "part1" and "part2").
+  int length;
+  const char *continuation = hdr.value_get("continuation", 12, &length);
+
+  if ((13 != length)) {
+    printf("FAILED: continue header folded line was too short\n");
+    return (failures_to_status("test_mime", 1));
+  }
+
+  if (strncmp(continuation + 5, "   ", 3)) {
+    printf("FAILED: continue header unfolding did not produce correct WS's\n");
+    return (failures_to_status("test_mime", 1));
+  }
+
+  if (strncmp(continuation, "part1   part2", 13)) {
+    printf("FAILED: continue header unfolding was not correct\n");
+    return (failures_to_status("test_mime", 1));
+  }
+
   hdr.field_delete("not_there", 9);
   hdr.field_delete("accept", 6);
   hdr.field_delete("scooby", 6);
@@ -539,7 +561,7 @@ HdrTest::test_mime()
 
   hdr.set_age(9999);
 
-  int length = hdr.length_get();
+  length = hdr.length_get();
   printf("hdr.length_get() = %d\n", length);
 
   time_t t0, t1, t2;
diff --git a/proxy/hdrs/MIME.cc b/proxy/hdrs/MIME.cc
index fa3eec6..9a424b4 100644
--- a/proxy/hdrs/MIME.cc
+++ b/proxy/hdrs/MIME.cc
@@ -2435,6 +2435,12 @@ mime_scanner_get(MIMEScanner *S, const char **raw_input_s, const char
*raw_input
     case MIME_PARSE_AFTER:
       // After a LF. Might be the end or a continuation.
       if (ParseRules::is_ws(*raw_input_c)) {
+        char *unfold = const_cast<char *>(raw_input_c - 1);
+
+        *unfold-- = ' ';
+        if (ParseRules::is_cr(*unfold)) {
+          *unfold = ' ';
+        }
         S->m_state = MIME_PARSE_INSIDE; // back inside the field.
       } else {
         S->m_state = MIME_PARSE_BEFORE; // field terminated.

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message