X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Fupdate_card.sh;h=a1143c3d72057359ef7b42a07c919c3d21ef33f4;hp=a810476a5ca3e6d66d71915d246852cd3f8e0977;hb=786c12839c61826d4d06e2a2f62d1a3d8b7ea780;hpb=891dee2c19bd2836e6818bffce1174f30c5d1ae5 diff --git a/actions/update_card.sh b/actions/update_card.sh index a810476..a1143c3 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,30 +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;([;,\\]);\\\1;g; s;\n;\\n;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" <