X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Fupdate_card.sh;h=a1143c3d72057359ef7b42a07c919c3d21ef33f4;hp=f18c9ee3e659832c2da4e568a967385188220bf9;hb=786c12839c61826d4d06e2a2f62d1a3d8b7ea780;hpb=aedb6776919b351df7df7c310c238c41317ddc44 diff --git a/actions/update_card.sh b/actions/update_card.sh index f18c9ee..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,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;([;,\\]);\\\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" <