sfeed_content: add link as base URL for HTML content - sfeed_curses - sfeed cur… | |
git clone git://git.codemadness.org/sfeed_curses | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7bf22e2b26d6e81c28404cc0230b7a0b6dee54c3 | |
parent cdc9b56cff13200d3f6abe4401a308c38a99a70c | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Sun, 24 Oct 2021 20:59:50 +0200 | |
sfeed_content: add link as base URL for HTML content | |
This is useful for HTML viewers to use the base href as the base URL for | |
relative links in the HTML content. | |
Diffstat: | |
M sfeed_content | 9 ++++++++- | |
1 file changed, 8 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/sfeed_content b/sfeed_content | |
@@ -43,7 +43,14 @@ BEGIN { | |
next; | |
print ""; | |
if ($5 == "html") { | |
- print unescape($4) | htmlconv; | |
+ # use the link of the item as the base URL for relative URLs in | |
+ # HTML content. | |
+ base = $3; | |
+ if (length(base)) { | |
+ gsub("\"", "%22", base); # encode quotes. | |
+ base = "<base href=\"" base "\"/>\n"; | |
+ } | |
+ print base unescape($4) | htmlconv; | |
close(htmlconv); | |
} else { | |
print unescape($4); |