Add a decode() function to decode HTML entities and escape possible `|' - gophercgis - Collection of gopher CGI/DCGI for geomyidae
(HTM) hg clone https://bitbucket.org/iamleot/gophercgis
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) changeset f160deab50628cdc0c854143e78ae5c89e452d3d
(DIR) parent 207b92a909a537dfef21972e5f99ca25f63055ba
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sun, 9 Dec 2018 15:00:53
Add a decode() function to decode HTML entities and escape possible `|'
Diffstat:
ilmanifesto/edition.dcgi | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff -r 207b92a909a5 -r f160deab5062 ilmanifesto/edition.dcgi
--- a/ilmanifesto/edition.dcgi Sat Dec 08 23:52:34 2018 +0100
+++ b/ilmanifesto/edition.dcgi Sun Dec 09 15:00:53 2018 +0100
@@ -12,6 +12,14 @@
curl -A Googlebot-News -Lgs -- "https://ilmanifesto.it/edizione/il-manifesto-del-${edition}/" |
awk -v cgi="${ARTICLE_CGI}" '
+function decode(s)
+{
+ gsub(/’/, "\047", s);
+ gsub("\\|", "\\|", s)
+
+ return s
+}
+
/<article class="edition-toc__item"/ {
# Extract all article information to generate the menu
n = split($0, a, /<\/article>/)
@@ -27,6 +35,10 @@
match(a[i], /<p>.*<\/p>$/)
description = substr(a[i], RSTART + 3, RLENGTH - 7)
+ title = decode(title)
+ author = decode(author)
+ description = decode(description)
+
if (href && title) {
if (author) {
entry = title ", " author