[packages/rpm-build-tools/merge-pld-builder-client: 2301/2675] add hsc function to escape xml chars

glen glen at pld-linux.org
Mon Dec 19 22:04:17 CET 2016


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

    add hsc function to escape xml chars

 make-request.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/make-request.sh b/make-request.sh
index a062fbc..7251406 100755
--- a/make-request.sh
+++ b/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/packages/rpm-build-tools.git/commitdiff/cca6584b96e6c33d0732d559e43e100d804e2ecd



More information about the pld-cvs-commit mailing list