Summary: | ASTERISK-03493: [patch] Fixes negative len in colon ${EXTEN:-4) | ||
Reporter: | Olle Johansson (oej) | Labels: | |
Date Opened: | 2005-02-12 16:03:39.000-0600 | Date Closed: | 2008-01-15 15:25:41.000-0600 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) colondoc.txt ( 1) extencolon.STABLE.patch ( 2) extencolon.txt | |
Description: | As reported on the #asterisk-doc channel on IRC; EXTEN:-7 did not do the right thing. I belive this patch fixes it. Disclaimer on file ****** ADDITIONAL INFORMATION ****** This is a bug in CVS stable as well | ||
Comments: | By: Olle Johansson (oej) 2005-02-12 16:18:04.000-0600 Added extra documentation to README.variables By: Jared Smith (jsmith) 2005-02-12 16:37:58.000-0600 This patch applies cleanly to HEAD, and fixes the problem, as demonstrated below: exten => 124,1,SetVar(FOO=1234567890ABCDEFG) exten => 124,2,NoOp(${FOO:7}) exten => 124,3,NoOp(${FOO:-7}) exten => 124,4,NoOp(${FOO:7:3}) exten => 124,5,NoOp(${FOO:7:-3}) exten => 124,6,NoOp(${FOO:-7:-3}) results in: -- Executing SetVar("Zap/1-1", "FOO=1234567890ABCDEFG") in new stack -- Executing NoOp("Zap/1-1", "890ABCDEFG") in new stack -- Executing NoOp("Zap/1-1", "ABCDEFG") in new stack -- Executing NoOp("Zap/1-1", "890") in new stack -- Executing NoOp("Zap/1-1", "890ABCDEFG") in new stack -- Executing NoOp("Zap/1-1", "ABCDEFG") in new stack By: Jared Smith (jsmith) 2005-02-12 16:45:48.000-0600 I'm adding a patch against STABLE, based on oej's patch for HEAD. My disclaimer is also on file. By: Mark Spencer (markster) 2005-02-12 20:14:52.000-0600 The use of "-3" as the second arg does not appear to be documented. What's it supposed to dO? By: Jared Smith (jsmith) 2005-02-12 21:39:33.000-0600 I used negative numbers in the second field (the -3 in my example) just to make sure that putting a negative value in that field wouldn't cause problems. By definition, the second field is a length, so a negative should be treated just like 0, and it is. In short, I was testing to make sure a negative value wouldn't crash Asterisk. By: Mark Spencer (markster) 2005-02-13 01:05:12.000-0600 What's wrong with the output you pasted? By: Tilghman Lesher (tilghman) 2005-02-13 08:26:53.000-0600 jsmith: according to your bugnote, -3 in the second field should be treated like a 0, but in your demonstration example, it's treated like it didn't exist, not like 0. i.e. ${FOO:-7:-3} should return "", not "ABCDEFG". By: Olle Johansson (oej) 2005-02-13 09:26:45.000-0600 The only documentation I got is "If length is omitted or is negative, then all the rest of the string beginning at offset is returned. " By: Tilghman Lesher (tilghman) 2005-02-13 09:37:00.000-0600 Okay, as long as that's what the documentation is, that's the correct behavior. I just wanted to point out an inconsistency in the bugnotes of this bug. By: Olle Johansson (oej) 2005-02-13 12:34:03.000-0600 ...believe this is ready for CVS head and stable... By: Mark Spencer (markster) 2005-02-13 12:49:14.000-0600 This isn't ready for CVS until someone explains to me why this patch is necessary. The posted example from jsmith appears to be the current behavior, which appears to be accurate with respect to the documentation (which currently does not mention negative numbers -- such behavior is presumably undefined and adds no value as far asi know). By: Olle Johansson (oej) 2005-02-13 13:42:26.000-0600 As stated above: ${EXTEN:-7} is broken. This patch fixes it. Jared's tests confirms that it is fixed. By: Mark Spencer (markster) 2005-02-13 14:00:02.000-0600 What's wrong with the -7 example? Shouldn't it return the last 7 characters, as in his example? By: Olle Johansson (oej) 2005-02-13 14:31:50.000-0600 MARK! Jared's example is ***AFTER*** he did apply this patch, to confirm that this patch works... If you test it WITHOUT this patch, it will not work. By: Olle Johansson (oej) 2005-02-13 14:44:26.000-0600 [ Context 'extensions' created by 'pbx_config' ] '9507' => 1. setvar(SKREP=1234567890) [pbx_config] 2. noop(${SKREP:2}) [pbx_config] 3. noop(${SKREP:-2}) [pbx_config] 4. noop(${SKREP:-4}) [pbx_config] 5. noop(${SKREP:-7}) [pbx_config] 6. noop(${SKREP:-9}) [pbx_config] 7. noop(${SKREP:-9:2}) [pbx_config] 8. noop(${SKREP:4:2}) [pbx_config] 9. congestion() [pbx_config] ------------- -- Executing SetVar("SIP/olle-6bad", "sipcall=9507 - localhost") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'Goto' -- Executing Goto("SIP/olle-6bad", "sipusers-inbound|9507|1") in new stack -- Goto (sipusers-inbound,9507,1) Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'SetVar' -- Executing SetVar("SIP/olle-6bad", "SKREP=1234567890") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "34567890") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "90") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "7890") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "456") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "2") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "23") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'NoOp' -- Executing NoOp("SIP/olle-6bad", "56") in new stack Feb 13 21:39:27 DEBUG[71377]: pbx.c:1294 pbx_extension_helper: Launching 'Congestion' -- Executing Congestion("SIP/olle-6bad", "") in new stack ----------------- -7 and -9 is WRONG. By: Mark Spencer (markster) 2005-02-13 14:58:23.000-0600 Okies, added to CVS head, thanks! By: Russell Bryant (russell) 2005-02-18 18:29:08.000-0600 fixed in 1.0 By: Digium Subversion (svnbot) 2008-01-15 15:25:17.000-0600 Repository: asterisk Revision: 5023 U trunk/doc/README.variables U trunk/pbx.c ------------------------------------------------------------------------ r5023 | markster | 2008-01-15 15:25:17 -0600 (Tue, 15 Jan 2008) | 2 lines Fix colon expansion (bug ASTERISK-3493) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=5023 By: Digium Subversion (svnbot) 2008-01-15 15:25:41.000-0600 Repository: asterisk Revision: 5051 U branches/v1-0/pbx.c ------------------------------------------------------------------------ r5051 | russell | 2008-01-15 15:25:41 -0600 (Tue, 15 Jan 2008) | 2 lines fix ${EXTEN:X} where X < 0 (bug ASTERISK-3493) ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=5051 |