From: Fletcher T. Penney Date: Sat, 8 Sep 2018 18:29:08 +0000 (-0400) Subject: FIXED: Ensure newline at end of header contents when importing from OPML/ITMZ X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2adf0812d5d0bdd5b0da98e3552a812e498a2360;p=multimarkdown FIXED: Ensure newline at end of header contents when importing from OPML/ITMZ --- 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) {