[asterisk-bugs] [Asterisk 0010613]: Unable to use variables containing times

noreply at bugs.digium.com noreply at bugs.digium.com
Thu Aug 30 21:36:02 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=10613 
====================================================================== 
Reported By:                Karl Anderson
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   10613
Category:                   Functions/func_logic
Reproducibility:            always
Severity:                   tweak
Priority:                   normal
Status:                     new
Asterisk Version:            1.4.10.1  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             08-30-2007 18:38 CDT
Last Modified:              08-30-2007 21:36 CDT
====================================================================== 
Summary:                    Unable to use variables containing times
Description: 
Due to the syntax of the function IF I am unable to use it (or any other)
logic functions to make decisions on variables holding times.  Example:

Set(REDIRECT_TIME=${ODBC_PREF(${MACRO_CONTEXT}|${MACRO_EXTEN}|REDIRECT_TIME)})
Set(REDIRECT_TIME=${IF($["REDIRECT_TIME" !=
""]?${REDIRECT_TIME}:"*|*|*|*")})
GotoIfTime(${REDIRECT_TIME}}?INSIDE_RANGE)

1. A odbc connection is used to query a MySQL table for this
context/extensions REDIRECT_TIME.
2. If there was no return from the MySQL then use wildcards (works)
otherwise use the time found (broken)
3. Goto based on the time

In this example if the MySQL holds a time then func if incorrectly uses
the first ':' (8:00-17:00|mon-fri) effectively making the if statement:
            ^


IF REDIRECT_TIME ? 8 : 00-17:00|mon-fri

Which fails.  After looking into the source code I (albeit not a
programmer) recommend either not striping quotes first (if present) or
using a regex to find the last occurance of ':' 
====================================================================== 

---------------------------------------------------------------------- 
 Karl Anderson - 08-30-07 21:36  
---------------------------------------------------------------------- 
Sorry, typo while writing report.  Yes, I meant the variable is not blank,
as posted would always evaluate as true.  However, the issue is not with
the conditional engine but rather what is set as 'iftrue', 'iffalse' when
there are multiple colons.  I did realize that the last occurance of the
colon would not be a good test as the last return is optional.  I would
like to recommend a regex such as "(.{1,})\\?(.*):(.{1,})".  as that would
force the proper format and adapt to optional fields. Or similar, I think
that wouldn't work for dates as the false value (note the above is untested
and written on the fly).  Anyway, sorry about the typo. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
08-30-07 21:36  Karl Anderson  Note Added: 0069763                          
======================================================================




More information about the asterisk-bugs mailing list