X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fupdate_card.sh;h=a1143c3d72057359ef7b42a07c919c3d21ef33f4;hb=d40eb749c3b9766eb85d843e712f1b86543232d2;hp=1be16765cd20e8f0bf9340679e1da274606e5edf;hpb=2805ee334bead55e2ab08b7c4dbdbf07dcebf8e9;p=confetti
diff --git a/actions/update_card.sh b/actions/update_card.sh
index 1be1676..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,28 +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]//;/,}"
-[ -n "${_POST[hi_number]}" -o -n "${_POST[hi_company]}" ] \
-&& _POST[X-HEALTH-INSURANCE]="${_POST[hi_number]//;/,};${_POST[hi_company]//;/,}"
+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" ] || _POST[hi_company]="${_POST[hi_other]}"
+[ -n "${_POST[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" <