Browse code

kamctl: relaxed regex check on aor and sip uri

- it required a dot (.), not valid for ipv6 and single word domains
(e.g., localhost)
- now just match on USERNAME_RE@.+

Daniel-Constantin Mierla authored on 09/07/2019 07:35:08
Showing 1 changed files
... ...
@@ -667,7 +667,7 @@ in SIP_DOMAIN"
667 667
 
668 668
 # check the parameter if it is a valid address of record (user@domain)
669 669
 check_aor() {
670
-	echo "$1" | $EGREP "^$USERNAME_RE@.*\..*" >/dev/null
670
+	echo "$1" | $EGREP "^$USERNAME_RE@.+" >/dev/null
671 671
 	if [ $? -ne 0 ] ; then
672 672
 		echo "error: invalid AoR: $1" >&2
673 673
 		exit 1
... ...
@@ -676,7 +676,7 @@ check_aor() {
676 676
 
677 677
 # check the parameter if it is a valid address of record (user@domain)
678 678
 is_aor() {
679
-	echo "$1" | $EGREP "^$USERNAME_RE@.*\..*" >/dev/null
679
+	echo "$1" | $EGREP "^$USERNAME_RE@.+" >/dev/null
680 680
 	if [ $? -ne 0 ] ; then
681 681
 		false
682 682
 	else
... ...
@@ -686,7 +686,7 @@ is_aor() {
686 686
 
687 687
 # check the parameter if it is a valid SIP address of record (sip:user@domain)
688 688
 check_sipaor() {
689
-	echo "$1" | $EGREP "^sip(s)?:$USERNAME_RE@.*\..*" >/dev/null
689
+	echo "$1" | $EGREP "^sip(s)?:$USERNAME_RE@.+" >/dev/null
690 690
 	if [ $? -ne 0 ] ; then
691 691
 		echo "error: invalid SIP AoR: $1" >&2
692 692
 		exit 1
... ...
@@ -697,7 +697,7 @@ check_sipaor() {
697 697
 # quite simplified now -- it captures just very basic
698 698
 # errors
699 699
 check_uri() {
700
-	echo "$1" | $EGREP "^sip(s)?:($USERNAME_RE@)?.*\..*"  > /dev/null
700
+	echo "$1" | $EGREP "^sip(s)?:($USERNAME_RE@)?.+"  > /dev/null
701 701
 	if [ $? -ne 0 ] ; then
702 702
 		echo "error: invalid SIP URI: $1" >&2
703 703
 		exit 1