#!/bin/bash # Copyright (C) 2008 Lonnie Abelbeck # This is free software, licensed under the GNU General Public License # version 3 as published by the Free Software Foundation; you can # redistribute it and/or modify it under the terms of the GNU # General Public License; and comes with ABSOLUTELY NO WARRANTY. # # CallerID Name fix for XHTML entities # # [read AGI variables] declare -a array while read -e ARG && [ "${ARG}" ] ; do array=(`echo ${ARG} |sed -e 's/://' -e 's/"//g'`) export ${array[0]}="${array[1]}" done # [results function] checkresults() { while read line do case ${line:0:4} in "200 " ) return;; "510 " ) return;; "520 " ) return;; * ) ;; #keep on reading those Invlid command #command syntax until "520 End ..." esac done } # [main] CIDNAME=`echo -n "${agi_calleridname}" |sed \ -e 's/&[a-zA-Z]*;//' -e 's/&#[0-9]*;//'` if [ "${CIDNAME:0:15}" = "${agi_calleridname}" ]; then exit 0 fi CIDNAME=`echo -n "${agi_calleridname}" |sed \ -e 's/&/\&/g' \ -e 's/&/\&/g' \ -e "s/'/\'/g" \ -e "s/"/\'/g" \ -e 's/ / /g' \ -e 's/<//g' \ -e 's/–/-/g' \ -e 's/—/-/g' \ -e 's/&#[0-9]*;/ /g' \ -e 's/&[a-zA-Z]*;/ /g'` CIDNAME="${CIDNAME:0:15}" # limit names to 15 characters echo "SET CALLERID \"${CIDNAME}\"<${agi_callerid}>" checkresults exit 0