From: paul Date: Sat, 12 Nov 2016 02:44:54 +0000 (+0000) Subject: improved escaping when writing cards X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=d6ca659b75648cf1001d731484e643aa35888dd7;p=confetti improved escaping when writing cards svn path=/trunk/; revision=143 --- diff --git a/actions/update_card.sh b/actions/update_card.sh index f18c9ee..c2a4a71 100755 --- a/actions/update_card.sh +++ b/actions/update_card.sh @@ -17,7 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -cgi_post cgi_refdata filter="&filter=${_REF[filter]}" @@ -29,31 +28,40 @@ tempfile="$_DATA/temp/$card" cardfile="$_DATA/vcard/$card" attfile="$_DATA/mappings/attendance" -_POST[0N]="${_POST[0N]//;/,}" -_POST[1N]="${_POST[1N]//;/,}" -_POST[2N]="${_POST[2N]//;/,}" -_POST[3N]="${_POST[3N]//;/,}" -_POST[4N]="${_POST[4N]//;/,}" +vcf_escape(){ + for each in "$@"; do + printf %s\\n "$each" \ + | sed -r ':X;$!{N;bX}; s;\r\n;\n;g; s;([\n\;,\\]);\\\1;g;' + done \ + | sed -r ':X;$!{N;bX}; s;\n;\;;g' +} -[ "$_POST[hi_select]" = "list" ] && hi_company="${_POST[hi_company]}" || hi_company="${_POST[hi_other]}" +[ "${_POST[hi_select]}" = "list" ] || _POST[hi_company]="${_POST[hi_other]}" [ -n "${_POST[hi_company]}${_POST[hi_number]}${_POST[hi_status]}" ] \ -&& _POST[X-HEALTH-INSURANCE]="${hi_company//;/,};${_POST[hi_number]//;/,};${_POST[hi_status]//;/,}" +&& _POST[X-HEALTH-INSURANCE]="$(vcf_escape "${_POST[hi_company]}" "${_POST[hi_number]}" "${_POST[hi_status]}")" sed -r 's;$;\r;' >"$tempfile" <