This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/7.1.x by this push:
new f615955 TS-4930: Unfolds request headers that are using obs
continuations
f615955 is described below
commit f615955a6b3665c93a8d14e9c61dc3e82d8e5029
Author: Leif Hedstrom <[email protected]>
AuthorDate: Tue Oct 4 11:22:05 2016 -0600
TS-4930: Unfolds request headers that are using obs continuations
(cherry picked from commit da4a9f6ed21fb0f0694a9bc1e0ae4a616d23f610)
---
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 1023e6f..a2dcfaf 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
['"[email protected]" <[email protected]>'].