+ if (content_top->boundary) {
+ if (!find_boundary())
+ return;
+ }
+
+ do {
+ /* process any boundary lines */
+ if (content_top->boundary && is_multipart_boundary(line)) {
+ /* flush any leftover */
+ if ((transfer_encoding == TE_BASE64) &&
+ (np != newline)) {
+ handle_filter(newline);
+ }
+ if (!handle_boundary())
+ return;
+ }
+
+ /* Unwrap transfer encoding and optionally
+ * normalize the log message to UTF-8.
+ */
+ decode_transfer_encoding(line);
+ if (metainfo_charset)
+ convert_to_utf8(line, charset);
+
+ switch (transfer_encoding) {
+ case TE_BASE64:
+ {
+ char *op = line;
+
+ /* binary data most likely doesn't have newlines */
+ if (message_type != TYPE_TEXT) {
+ rc = handle_filter(line);
+ break;
+ }
+
+ /* this is a decoded line that may contain
+ * multiple new lines. Pass only one chunk
+ * at a time to handle_filter()
+ */
+
+ do {
+ while (*op != '\n' && *op != 0)
+ *np++ = *op++;
+ *np = *op;
+ if (*np != 0) {
+ /* should be sitting on a new line */
+ *(++np) = 0;
+ op++;
+ rc = handle_filter(newline);
+ np = newline;
+ }
+ } while (*op != 0);
+ /* the partial chunk is saved in newline and
+ * will be appended by the next iteration of fgets
+ */