<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17947">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">manager.c: Generate valid XML if attributes have leading digits.<br><br>XML element attributes are not permitted to begin with digits, so<br>prepend with an underscore to avoid failing XML validation.<br><br>This is not backwards compatible but my assumption is that compliant<br>XML parsers would already have been complaining about this.<br><br>ASTERISK-29886 #close<br><br>Change-Id: Icfaa56a131a082d803e9b7db5093806d455a0523<br>---<br>M main/manager.c<br>1 file changed, 14 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/47/17947/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/manager.c b/main/manager.c</span><br><span>index 23e5575..1a1016f 100644</span><br><span>--- a/main/manager.c</span><br><span>+++ b/main/manager.c</span><br><span>@@ -7644,6 +7644,7 @@</span><br><span> /* store in a local buffer to avoid calling ast_str_append too often */</span><br><span> char buf[256];</span><br><span> char *dst = buf;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *save = src;</span><br><span> int space = sizeof(buf);</span><br><span> /* repeat until done and nothing to flush */</span><br><span> for ( ; *src || dst != buf ; src++) {</span><br><span>@@ -7657,10 +7658,19 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if ( (mode & 2) && !isalnum(*src)) {</span><br><span style="color: hsl(0, 100%, 40%);">- *dst++ = '_';</span><br><span style="color: hsl(0, 100%, 40%);">- space--;</span><br><span style="color: hsl(0, 100%, 40%);">- continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (mode & 2) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (save == src && isdigit(*src)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The first character of an XML attribute cannot be a digit */</span><br><span style="color: hsl(120, 100%, 40%);">+ *dst++ = '_';</span><br><span style="color: hsl(120, 100%, 40%);">+ *dst++ = *src;</span><br><span style="color: hsl(120, 100%, 40%);">+ space -= 2;</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!isalnum(*src)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Replace non-alphanumeric with an underscore */</span><br><span style="color: hsl(120, 100%, 40%);">+ *dst++ = '_';</span><br><span style="color: hsl(120, 100%, 40%);">+ space--;</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> switch (*src) {</span><br><span> case '<':</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17947">change 17947</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/+/17947"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Icfaa56a131a082d803e9b7db5093806d455a0523 </div>
<div style="display:none"> Gerrit-Change-Number: 17947 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>