diff options
Diffstat (limited to 'sfeed_opml_export')
-rwxr-xr-x | sfeed_opml_export | 29 |
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@'@\'@g" -e 's@<@\<@g' -e 's@>@\>@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("&", "\\&"); + gsub("\"", "\\""); + gsub("'"'"'", "\\'"); + gsub("<", "\\<"); + gsub(">", "\\>"); + + print "\t<outline title=\"" $1 "\" text=\""$1"\" xmlUrl=\""$2"\" htmlUrl=\""$3"\"/>"; +}' cat <<! </body> |