X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=cards%2Fupdate_card.sh;h=1975e4ea2aa66afa8bf5851965d7680ebb402118;hp=b16ea0549c8548fd727d23b78de7ed6e54928ac5;hb=bab7cadaeae32434eb16872bd8e09449817d4f90;hpb=39d5084924d723c5bbea52c2b62fdfc39d39fe23 diff --git a/cards/update_card.sh b/cards/update_card.sh index b16ea05..1975e4e 100755 --- a/cards/update_card.sh +++ b/cards/update_card.sh @@ -27,6 +27,9 @@ card="$(POST card)" cardfile="$_DATA/vcard/$card" attfile="$_DATA/mappings/attendance" +action="$(POST action)" +newfield="$(POST newfield)" + if ! tempfile=$(CHECK_SLOCK "$cardfile"); then SET_COOKIE 0 message="NO VALID FILE LOCK" REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}" @@ -61,18 +64,20 @@ for field in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*'); do # ;; TEL) vcf="$(pdi_update_attrib "$vcf" TEL $cnt TYPE="$(POST teltype $cnt |grep -Exm1 'HOME|WORK|CELL|FAX')")" - vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(POST "$field" "$cnt")")" + vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(vcf_escape "$(POST "$field" "$cnt")")")" ;; *) - vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(POST "$field" "$cnt")")" + vcf="$(pdi_update_value "$vcf" "$field" "$cnt" "$(vcf_escape "$(POST "$field" "$cnt")")")" ;; esac done; done -[ "$(POST action)" = addfield ] && vcf="$(vcf_update_field "$vcf" "$(POST newfield)" $(($(pdi_count $(POST newfield)) + 1)) '')" -printf '%s' "$vcf" >"$tempfile" +if [ "$action" = addfield ]; then + vcf="$(pdi_update_value "$vcf" "$newfield" $(( $(pdi_count "$vcf" "$newfield") + 1 )) '')" +fi +printf '%s' "$vcf" |grep -vx '' >"$tempfile" -case "$(POST action)" in +case "$action" in addfield) REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}" ;;