republique

helper scripts for www.republique-numerique.fr
git clone https://a3nm.net/git/republique/
Log | Files | Refs | README

commit 50e487e6ed56d98ba329ef1187c65760c8e15255
parent 216af807c0b0bc71537caa8c69b1c9e64ab23ff0
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed, 14 Oct 2015 23:06:27 +0100

escape to be safe

Diffstat:
escape.sh | 5+++++
maketable.sh | 15+++++++++++----
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/escape.sh b/escape.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# http://stackoverflow.com/a/12873723/414272 + +sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' + diff --git a/maketable.sh b/maketable.sh @@ -8,7 +8,8 @@ cat head >$2/prop_pos.html echo "<h1>Propositions par votes positifs décroissants</h1>" >> $2/prop_pos.html echo "<table>" >> $2/prop_pos.html echo "$HEADER" >> $2/prop_pos.html -grep '^opinion/[0-9]*\s' "$1" | sed 's_^opinion/__' | sort -k3,3nr | +grep '^opinion/[0-9]*\s' "$1" | sed 's_^opinion/__' | + sort -k3,3nr | ./escape.sh | awk -f ./fmt.awk >> $2/prop_pos.html echo "</table></body></html>" >> $2/prop_pos.html @@ -16,7 +17,8 @@ cat head >$2/prop_tot.html echo "<h1>Propositions par votes totaux décroissants</h1>" >> $2/prop_tot.html echo "<table>" >> $2/prop_tot.html echo "$HEADER" >> $2/prop_tot.html -grep '^opinion/[0-9]*\s' "$1" | sed 's_^opinion/__' | sort -k6,6nr | +grep '^opinion/[0-9]*\s' "$1" | sed 's_^opinion/__' | + sort -k6,6nr | ./escape.sh | awk -f ./fmt.awk >> $2/prop_tot.html echo "</table></body></html>" >> $2/prop_tot.html @@ -26,7 +28,9 @@ echo "<h1>Modifications par votes positifs décroissants</h1>" >> $2/modi_pos.ht echo "<table>" >> $2/modi_pos.html echo "$HEADER" >> $2/modi_pos.html grep '^opinion/[0-9]*/version/[0-9]*\s' "$1" | sed 's_^[^\t]*/__' | - sort -k3,3nr | awk -f ./fmt.awk \ + sort -k3,3nr | + ./escape.sh | + awk -f ./fmt.awk \ >> $2/modi_pos.html echo "</table></body></html>" >> $2/modi_pos.html @@ -35,7 +39,9 @@ echo "<h1>Modifications par votes totaux décroissants</h1>" >> $2/modi_tot.html echo "<table>" >> $2/modi_tot.html echo "$HEADER" >> $2/modi_tot.html grep '^opinion/[0-9]*/version/[0-9]*\s' "$1" | sed 's_^[^\t]*/__' | - sort -k6,6nr | awk -f ./fmt.awk \ + sort -k6,6nr | + ./escape.sh | + awk -f ./fmt.awk \ >> $2/modi_tot.html echo "</table></body></html>" >> $2/modi_tot.html @@ -45,6 +51,7 @@ echo "<h1>Arguments par votes décroissants</h1>" >> $2/argu_pos.html echo "<table>" >> $2/argu_pos.html echo "$HEADER" >> $2/argu_pos.html grep '^[^ ]*/argument/' "$1" | sed 's_^[^\t]*/__' | sort -k3,3nr | + ./escape.sh | awk -f ./fmt.awk \ >> $2/argu_pos.html echo "</table></body></html>" >> $2/argu_pos.html