[asterisk-bugs] [Asterisk 0017637]: [patch] STRFTIME in globals using commas returns incorrect value
Asterisk Bug Tracker
noreply at bugs.digium.com
Tue Jul 13 22:20:49 CDT 2010
A NOTE has been added to this issue.
======================================================================
https://issues.asterisk.org/view.php?id=17637
======================================================================
Reported By: wcselby
Assigned To:
======================================================================
Project: Asterisk
Issue ID: 17637
Category: Core/Configuration
Reproducibility: always
Severity: minor
Priority: normal
Status: new
Asterisk Version: 1.4.33.1
JIRA:
Regression: No
Reviewboard Link:
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2010-07-13 15:36 CDT
Last Modified: 2010-07-13 22:20 CDT
======================================================================
Summary: [patch] STRFTIME in globals using commas returns
incorrect value
Description:
I'm trying to declare a few date-related global variables to ease my
dialplan. When I declare the following in the [globals] context of
extensions.conf, I get unexpected results:
YEAR = ${STRFTIME(${EPOCH},,%Y)}
MONTH = ${STRFTIME(${EPOCH},,%m)}
DAY = ${STRFTIME(${EPOCH},,%d)}
TIMESTAMP = ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}
If I evaluate these variables in the dialplan later, using
exten => 7777,n,Verbose(${TIMESTAMP} - ${YEAR} - ${MONTH} - ${DAY})
My output is as follows:
-- Executing [7777 at phones:3] Verbose("SIP/2625-0000d5f0", "Tue Jul 13
11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue
Jul 13 11:08:42 2010") in new stack
Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42 2010 - Tue Jul 13 11:08:42
2010 - Tue Jul 13 11:08:42 2010
However, the following line:
exten => 7777,n,Verbose(${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} -
${STRFTIME(${EPOCH},,%Y)} - ${STRFTIME(${EPOCH},,%m)} -
${STRFTIME(${EPOCH},,%d)})
evaluates with what I expect:
-- Executing [7777 at phones:4] Verbose("SIP/2625-0000d5f0",
"20100713-110853 - 2010 - 07 - 13") in new stack
20100713-110853 - 2010 - 07 - 13
======================================================================
----------------------------------------------------------------------
(0124541) tilghman (administrator) - 2010-07-13 22:20
https://issues.asterisk.org/view.php?id=17637#c124541
----------------------------------------------------------------------
This patch will fix the problem. Unfortunately, it creates a completely
new problem with backwards compatibility. Anybody who currently sets
global variables and uses a comma as a literal character would find that
their dialplan breaks on the version where this patch might appear. Given
our reticence to break existing dialplans, I feel as though we might wish
to simply document this behavior more clearly and leave the patch to be
applied only by people who definitely want the different behavior.
This is not an issue in 1.6 and forward, because commas are not treated
differently in those versions in globals versus dialplan contexts. So, I'm
going to call this a documentation bug and leave it at that.
Issue History
Date Modified Username Field Change
======================================================================
2010-07-13 22:20 tilghman Note Added: 0124541
======================================================================
More information about the asterisk-bugs
mailing list