sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit dd00baa7ecde11cd7a6858203ee372db3b6dea60
parent 7d1a09873ed080ad438adf4ad4d2800f93cc0271
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 10 Dec 2017 13:36:41 +0100

sfeed_opml_import/sfeed_opml_export: allow " and \ in fields

make sure to escape them.

Diffstat:
Msfeed_opml_export | 11++++++++++-
Msfeed_opml_import.c | 10+++++++---
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/sfeed_opml_export b/sfeed_opml_export @@ -22,11 +22,20 @@ loadconfig() { fi } +# escape(s) +escape() { + printf '%s' "$1" | sed 's@"@\&quot;@g' +} + # override feeds function to ouput opml XML. # feed(name, feedurl, [basesiteurl], [encoding]) feed() { + name=$(escape "$1") + xmlurl=$(escape "$2") + htmlurl=$(escape "$3") + printf '\t<outline title="%s" text="%s" xmlUrl="%s" htmlUrl="%s"/>\n' \ - "$1" "$1" "$2" "$3" + "${name}" "${name}" "${xmlurl}" "${htmlurl}" } # load config file. diff --git a/sfeed_opml_import.c b/sfeed_opml_import.c @@ -16,9 +16,13 @@ static char url[2048], text[256], title[256]; static void printsafe(const char *s) { - for (; *s; s++) - if (!iscntrl((int)*s) && *s != '\'' && *s != '\\') - putchar((int)*s); + for (; *s; s++) { + if (iscntrl((int)*s)) + continue; + if (*s == '\\' || *s == '\'') + putchar('\\'); + putchar((int)*s); + } } static void