<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13457">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">config.c: Skip UTF-8 BOMs if present when reading config files<br><br>ASTERISK-28667 #close<br><br>Change-Id: I4767ed365c98f3e1587b7653321048a31d8a53b2<br>---<br>M main/config.c<br>1 file changed, 12 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/57/13457/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/config.c b/main/config.c</span><br><span>index 8731ebb..ede7db2 100644</span><br><span>--- a/main/config.c</span><br><span>+++ b/main/config.c</span><br><span>@@ -2223,6 +2223,18 @@</span><br><span>                                                   continue;</span><br><span>                                            }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+                                         /* If there is a UTF-8 BOM, skip over it */</span><br><span style="color: hsl(120, 100%, 40%);">+                                           if (lineno == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+#define UTF8_BOM "\xEF\xBB\xBF"</span><br><span style="color: hsl(120, 100%, 40%);">+                                                 size_t line_bytes = strlen(buf);</span><br><span style="color: hsl(120, 100%, 40%);">+                                                      size_t bom_bytes = sizeof(UTF8_BOM) - 1;</span><br><span style="color: hsl(120, 100%, 40%);">+                                                      if (line_bytes >= bom_bytes</span><br><span style="color: hsl(120, 100%, 40%);">+                                                           && !memcmp(buf, UTF8_BOM, bom_bytes)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                            memmove(buf, &buf[3], line_bytes - bom_bytes + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+                                                        }</span><br><span style="color: hsl(120, 100%, 40%);">+#undef UTF8_BOM</span><br><span style="color: hsl(120, 100%, 40%);">+                                            }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                                          if (ast_test_flag(&flags, CONFIG_FLAG_WITHCOMMENTS)</span><br><span>                                                      && lline_buffer</span><br><span>                                                      && ast_str_strlen(lline_buffer)) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13457">change 13457</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13457"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I4767ed365c98f3e1587b7653321048a31d8a53b2 </div>
<div style="display:none"> Gerrit-Change-Number: 13457 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>