[projects/pld-builder.new: 1/2] add hsc function to escape xml chars

glen glen at pld-linux.org
Wed Oct 17 20:56:50 CEST 2012


commit 8727819ecbeb233d8dacb531fda6db80aa75f61a
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Oct 17 21:55:38 2012 +0300

    add hsc function to escape xml chars

 client/make-request.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/client/make-request.sh b/client/make-request.sh
index a062fbc..7251406 100755
--- a/client/make-request.sh
+++ b/client/make-request.sh
@@ -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,&,\&,g;s,<,\<,g;s,>,\>,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,&,\&,g;s,<,\<,g;s,>,\>,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,&,\&,g;s,<,\<,g;s,>,\>,g'
+		hsc "$post_command"
 		echo "</command>"
 		echo "		 <info></info>"
 		echo "$builders_xml"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ebe1342b660ce994d480d739d8515175294792d3



More information about the pld-cvs-commit mailing list