chiark / gitweb /
multipart: fix part splitter
[hippotat.git] / src / multipart.rs
index b97644167a7b87add93b339c236ed29685efdb6c..c8c035f4fdb52acc1ea74fe80cf5caf5ff012cc1 100644 (file)
@@ -82,7 +82,7 @@ pub fn process_boundary<'b>(warnings: &mut Warnings,
     };
   }
 
-  //dbg!(str::from_utf8(rhs));
+  //dbg!(DumpHex(rhs));
 
   Some(Component { name: part_name.unwrap_or(expected), payload: rhs })
 }
@@ -104,7 +104,7 @@ impl<'b> ComponentIterator<'b> {
     let part = &buf[0..next_boundary];
     let part = Self::payload_trim(part);
 
-    //dbg!(str::from_utf8(part));
+    //dbg!(DumpHex(part));
 
     (part, ComponentIterator {
       at_boundary: &buf[next_boundary..],
@@ -122,7 +122,9 @@ impl<'b> ComponentIterator<'b> {
     if self.at_boundary.is_empty() { return None }
 
     let mut comp = match {
+      //dbg!(DumpHex(self.boundary_finder.needle()));
       let boundary_len = self.boundary_finder.needle().len();
+      //dbg!(boundary_len);
       process_boundary(warnings,
                        &self.at_boundary[boundary_len..],
                        expected)?
@@ -137,10 +139,11 @@ impl<'b> ComponentIterator<'b> {
     let next_boundary = self.boundary_finder.find(&comp.payload)
       .ok_or(MissingBoundary)?;
 
+    self.at_boundary = &comp.payload[next_boundary..];
     comp.payload = Self::payload_trim(&comp.payload[0..next_boundary]);
-    self.at_boundary = &self.at_boundary[next_boundary..];
 
-    //dbg!(str::from_utf8(comp.payload));
+    //dbg!(DumpHex(comp.payload));
+    //dbg!(DumpHex(&self.at_boundary[0..5]));
 
     Some(comp)
   }