From 2e84c80b228b77335ce44fe0f7ff1edf022d2246 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 25 Sep 2010 15:04:12 +0200 Subject: Really fix parsing phones in go/so. --- localkannel-dispatch | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'localkannel-dispatch') diff --git a/localkannel-dispatch b/localkannel-dispatch index e9564db..91e5577 100755 --- a/localkannel-dispatch +++ b/localkannel-dispatch @@ -47,6 +47,7 @@ lastservicephone() { from=`uriunescape "$1"`; shift #to=`uriunescape "$1" | sed -e 's/\+/ /g'`; shift to=`uriunescape "$1"`; shift +# FIXME: avoid stripping ALL plusses set -- `uriunescape "$@" | sed -e 's/\+/ /g'` #set -- `uriunescape "$@"` app_raw="$1" @@ -239,16 +240,19 @@ and (if included) send MSG to subscribers." phones="$gophones" ;; esac +# FIXME: avoid juggling with leading plus here when no longer stripped from input +# FIXME: make country code optional again when plus no longer stripped from input # FIXME: Avoid hardcoding national prefix while [ -n "$1" ]; do - targetphone="$(echo "$1" | perl -pe 's/^(?=[^+])/+36/;' -e '/^\+\d+$/;')" +# targetphone="$(echo "$1" | perl -ne 's/^(?=[^+])/+36/;' -e '/^(\+\d\d\d+)$/ and print $1;')" + targetphone="$(echo "$1" | perl -ne '/^(\d\d\d+)$/ and print $1;')" [ -n "$targetphone" ] || continue # Sanity check - targetfrom=$(lastservicephone "$targetphone") - [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"." + targetfrom=$(lastservicephone "\+$targetphone") + [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number +$targetphone." - targetphones="${targetphones:+$targetphones }$targetphone" + targetphones="${targetphones:+$targetphones }\+$targetphone" shift done -- cgit v1.2.3