[asterisk-dev] [Code Review] 4132: config: Make ast_config_text_file_save and 'dialplan save' escape semicolons in values.

opticron reviewboard at asterisk.org
Thu Oct 30 15:39:18 CDT 2014



> On Oct. 30, 2014, 1:25 p.m., opticron wrote:
> > branches/13/main/utils.c, line 494
> > <https://reviewboard.asterisk.org/r/4132/diff/3/?file=68631#file68631line494>
> >
> >     This should be > instead of >= due to the need to write out a null terminator along with the escaped semicolon.
> >     
> >     Look at the degenerate case of input string ";" with an input buffer of length 2 (1 byte usable).

Ignore this one, I read the line incorrectly.


- opticron


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4132/#review13632
-----------------------------------------------------------


On Oct. 30, 2014, 12:09 p.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4132/
> -----------------------------------------------------------
> 
> (Updated Oct. 30, 2014, 12:09 p.m.)
> 
> 
> Review request for Asterisk Developers and Birger Harzenetter.
> 
> 
> Bugs: ASTERISK-20127
>     https://issues.asterisk.org/jira/browse/ASTERISK-20127
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> I've been locally patching for this issue for 2 years but now someone else (WIMPy) has run into the same problem.
> 
> When a config file is read, an unescaped semicolon signals comments which are stripped from the value before it's stored.  Escaped semicolons are then unescaped and become part of the value.  Both of these behaviors are normal and expected.  When the config is serialized either by 'dialplan save' or AMI/UpdateConfig however, the now unescaped semicolons are written as-is.  If you actually reload the file just saved, the unescaped semicolons are now treated as start of comments.
> 
> Example:
> 
> Lines such as 
> PAGING_HEADER = Call-Info: \;answer-after=0
> are being rewritten as 
> PAGING_HEADER = Call-Info: ;answer-after=0
> 
> On re-read, everything after the now-unescaped semicolon is read as a comment with the result that the file is effectively corrupted.
> 
> So...   Since true comments are stripped on read, any semicolons in ast_variable.value must have been escaped originally.  This patch re-escapes semicolons in ast_variable.values before they're written to file either by 'dialplan save' or config/ast_config_text_file_save which is called by AMI/UpdateConfig. I also fixed a few pre-existing formatting issues nearby in pbx_config.c
> 
> This patch is for 13 but it will be applied to 1.8 -> trunk.
> 
> 
> Diffs
> -----
> 
>   branches/13/pbx/pbx_config.c 426754 
>   branches/13/main/utils.c 426754 
>   branches/13/main/config.c 426754 
>   branches/13/include/asterisk/utils.h 426754 
> 
> Diff: https://reviewboard.asterisk.org/r/4132/diff/
> 
> 
> Testing
> -------
> 
> Testsuite results before and after match.
> tests/manager/config will be updated to test escaped semicolons.
> A new testsuite test will be written to test dialplan save.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141030/d951a34f/attachment-0001.html>


More information about the asterisk-dev mailing list