<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/4132/">https://reviewboard.asterisk.org/r/4132/</a>
     </td>
    </tr>
   </table>
   <br />




<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers and Birger Harzenetter.</div>
<div>By George Joseph.</div>


<p style="color: grey;"><i>Updated Oct. 30, 2014, 6:02 p.m.</i></p>



<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Changed ast_alloca's to variable length arrays.
</pre>
  </td>
 </tr>
</table>





<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-20127">ASTERISK-20127</a>


</div>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">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.
</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> (updated)</h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>branches/13/tests/test_strings.c <span style="color: grey">(426808)</span></li>

 <li>branches/13/pbx/pbx_config.c <span style="color: grey">(426808)</span></li>

 <li>branches/13/main/utils.c <span style="color: grey">(426808)</span></li>

 <li>branches/13/main/config.c <span style="color: grey">(426808)</span></li>

 <li>branches/13/include/asterisk/utils.h <span style="color: grey">(426808)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/4132/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>




  </div>
 </body>
</html>