[Home]

Summary:ASTERISK-08923: IF does not work when value contains : (colon)
Reporter:Benny Amorsen (amorsen)Labels:
Date Opened:2007-03-02 06:46:39.000-0600Date Closed:2011-06-07 14:08:05
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/Configuration
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:The IF function does not work if one of the values contain colon. It is impossible to quote the colon in a way which actually works.

With this in the dial plan:
exten => 1013,1,NoOp(${IF(1?http://foo/:http://bar/)})
exten => 1013,n,NoOp(${IF(1?"http://foo/":"http://bar/")})
exten => 1013,n,NoOp(${IF(1?http\://foo/:"http\://bar/)})
exten => 1013,n,NoOp(${IF(1?"http\://foo/":"http\://bar/")})

I get this output:

   -- Executing NoOp("SIP/774-097fdc80", "http") in new stack
   -- Executing NoOp("SIP/774-097fdc80", ""http") in new stack
   -- Executing NoOp("SIP/774-097fdc80", "http") in new stack
   -- Executing NoOp("SIP/774-097fdc80", ""http") in new stack


****** ADDITIONAL INFORMATION ******

(Why can't I select 1.2.15 in product version when reporting an issue?)
Comments:By: Steve Murphy (murf) 2007-03-02 11:28:03.000-0600

The documentation (show function IF) for this function is clear: the semicolon divides two options. It's a really simplistic parser, and no amount of quoting or backslashing will fool it.

I suggest trying a different approach:

(in AEL):

   if (condition)
      Set(x=http://foo/etc);
   else
      Set(x=http://bar/etc);

You could argue that we picked a bad sep char; but my guess is that no matter what char we chose, someone would be unhappy.