]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
add hsc function to escape xml chars
authorElan Ruusamäe <glen@delfi.ee>
Wed, 17 Oct 2012 18:55:38 +0000 (21:55 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Wed, 17 Oct 2012 18:55:38 +0000 (21:55 +0300)
client/make-request.sh

index a062fbc58d34cbca9adc66b95600668c4b564dc1..7251406019c645d09db8fa0673eecd1f8edc1163 100755 (executable)
@@ -108,6 +108,12 @@ print >> sys.stdout, "Request queued via HTTP."
        esac
 }
 
+# htmlspecialchars: escape <, > and &
+hsc() {
+       local input=$1
+       echo -E "$input" | sed -e 's,&,\&amp;,g;s,<,\&lt;,g;s,>,\&gt;,g'
+}
+
 # simple df_fetcher, based on packages/fetchsrc_request
 # TODO: tcp (smtp) mode
 # TODO: adjust for ~/.requestrc config
@@ -291,7 +297,7 @@ set_dist() {
        dist=$1
 }
 
-while [ $# -gt 0 ] ; do
+while [ $# -gt 0 ]; do
        case "$1" in
                -d | --dist | --distro)
                        set_dist $2
@@ -692,7 +698,7 @@ gen_req() {
                echo -E >&2 "* Command: $command"
                echo "  <batch id='$bid' depends-on=''>"
                echo "           <command flags='$command_flags'>"
-               echo -E "$command" | sed -e 's,&,\&amp;,g;s,<,\&lt;,g;s,>,\&gt;,g'
+               hsc "$command"
                echo "</command>"
                echo "           <info></info>"
                echo "$builders_xml"
@@ -748,7 +754,7 @@ gen_req() {
                echo -E >&2 "* Post-Command: $post_command"
                echo "  <batch id='$bid' depends-on='$depend'>"
                echo "           <command flags='$command_flags'>"
-               echo -E "$post_command" | sed -e 's,&,\&amp;,g;s,<,\&lt;,g;s,>,\&gt;,g'
+               hsc "$post_command"
                echo "</command>"
                echo "           <info></info>"
                echo "$builders_xml"
This page took 0.258815 seconds and 4 git commands to generate.