X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=cards%2Fnew_card.sh;h=1e37b7001af3c84a86d25409cdc8e81bc3e272ed;hp=db353e1a1943b4eb00c5daa6dfd36cd9815e6679;hb=1227cb42309bc7edd296e8fea288f68968b1e003;hpb=f494768fdc15212c82e1b8435170bbe6a00c5836 diff --git a/cards/new_card.sh b/cards/new_card.sh index db353e1..1e37b70 100755 --- a/cards/new_card.sh +++ b/cards/new_card.sh @@ -23,6 +23,22 @@ order="$(REF o)" uid="$(timeid)$(randomid)" # 32 Octets UID, starting with timestamp card="${uid}.vcf" +vcf_escape(){ + for each in "$@"; do + printf %s\\n "$each" \ + | sed -E ':X;$!{N;bX}; s;\r\n;\n;g; s;([;,\\]);\\\1;g; s;\n;\\n;g;' + done \ + | sed -E ':X;$!{N;bX}; s;\n;\;;g' +} + +IFS='|' read -r date fn ln bmonth byear tel tcell junk1 email junk2 note <<-EOF + $(POST seed |tr \\t \|) + EOF + +[ ${#byear} = 1 ] && byear="200$byear" +[ ${#byear} = 2 ] && byear="20$byear" +[ ${#bmonth} = 1 ] && bmonth="0$bmonth" + mkdir -p "${_DATA}/lock/vcard/" lockdir="${_DATA}/lock/vcard/${card}/" lockfile=${lockdir}/${SESSION_ID} @@ -31,12 +47,15 @@ if mkdir "$lockdir"; then cat >"$lockfile" <<-EOF BEGIN:VCARD VERSION:4.0 - N:;;;; - BDAY: - TEL: - EMAIL: + N:$(vcf_escape "$ln");$(vcf_escape "$fn");;; + FN:$(vcf_escape "$fn $ln") + BDAY:$(vcf_escape "${byear}-${bmonth}-01") + TEL:$(vcf_escape "$tel") + TEL;TYPE=CELL:$(vcf_escape "$tcell") + EMAIL:$(vcf_escape "$email") + X-ZACK-JOINDATE:$(vcf_escape "$date") ADR: - NOTE: + NOTE:$(vcf_escape "$note") UID:${uid} END:VCARD EOF