summaryrefslogtreecommitdiff
path: root/sfeed_opml_export
diff options
context:
space:
mode:
Diffstat (limited to 'sfeed_opml_export')
-rwxr-xr-xsfeed_opml_export29
1 files changed, 14 insertions, 15 deletions
diff --git a/sfeed_opml_export b/sfeed_opml_export
index 5d88165..82704a6 100755
--- a/sfeed_opml_export
+++ b/sfeed_opml_export
@@ -22,21 +22,11 @@ loadconfig() {
fi
}
-# escape(s)
-escape() {
- printf '%s' "$1" | sed -e 's@&@\&@g' -e 's@"@\"@g'\
- -e "s@'@\&#39;@g" -e 's@<@\&lt;@g' -e 's@>@\&gt;@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' \
- "${name}" "${name}" "${xmlurl}" "${htmlurl}"
+ # NOTE: TABs in field values are unsupported, be sane.
+ echo "$1 $2 $3"
}
# load config file.
@@ -51,9 +41,18 @@ cat <<!
<body>
!
-feeds
-# wait till all items are processed (concurrently).
-wait
+feeds | LC_ALL=C awk 'BEGIN {
+ FS = OFS = "\t";
+}
+{
+ gsub("&", "\\&amp;");
+ gsub("\"", "\\&quot;");
+ gsub("'"'"'", "\\&#39;");
+ gsub("<", "\\&lt;");
+ gsub(">", "\\&gt;");
+
+ print "\t<outline title=\"" $1 "\" text=\""$1"\" xmlUrl=\""$2"\" htmlUrl=\""$3"\"/>";
+}'
cat <<!
</body>