From 2adf0812d5d0bdd5b0da98e3552a812e498a2360 Mon Sep 17 00:00:00 2001 From: "Fletcher T. Penney" Date: Sat, 8 Sep 2018 14:29:08 -0400 Subject: [PATCH] FIXED: Ensure newline at end of header contents when importing from OPML/ITMZ --- Sources/libMultiMarkdown/itmz-reader.c | 13 +++++++++++++ Sources/libMultiMarkdown/opml-reader.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Sources/libMultiMarkdown/itmz-reader.c b/Sources/libMultiMarkdown/itmz-reader.c index 8387066..f82957f 100644 --- a/Sources/libMultiMarkdown/itmz-reader.c +++ b/Sources/libMultiMarkdown/itmz-reader.c @@ -301,6 +301,19 @@ void parse_itmz_token_chain(mmd_engine * e, token * chain) { if (out == metadata) { print_const(" \n"); + } else { + // Ensure that contents end in newline + if (out->currentStringLength) { + switch (out->str[out->currentStringLength - 1]) { + case '\n': + case '\r': + break; + + default: + d_string_append_c(out, '\n'); + break; + } + } } if (walker->type == ITMZ_TOPIC_SELF_CLOSE) { diff --git a/Sources/libMultiMarkdown/opml-reader.c b/Sources/libMultiMarkdown/opml-reader.c index 7dac9fe..97741d5 100644 --- a/Sources/libMultiMarkdown/opml-reader.c +++ b/Sources/libMultiMarkdown/opml-reader.c @@ -294,6 +294,19 @@ void parse_opml_token_chain(mmd_engine * e, token * chain) { if (out == metadata) { print_const(" \n"); + } else { + // Ensure that contents end in newline + if (out->currentStringLength) { + switch (out->str[out->currentStringLength - 1]) { + case '\n': + case '\r': + break; + + default: + d_string_append_c(out, '\n'); + break; + } + } } if (walker->type == OPML_OUTLINE_SELF_CLOSE) { -- 2.50.1