Joe Hansche commented on Bug JENKINS-14537

After some discussion and trying to find the best way to avoid this problem, I decided to XML entity-encode any "]]>" (and &) in the sublog text, which allows for recursive encoding and decoding:

<multi-scm-log version="2">
<sub-log scm="hudson.plugins.templateproject.ProxySCM">
<![CDATA[<multi-scm-log version="2">
<sub-log scm="hudson.plugins.git.GitSCM">
<![CDATA[&93;&93;&gt;
</sub-log>
<sub-log scm="hudson.plugins.git.GitSCM">
<![CDATA[&93;&93;&gt;
</sub-log>
</multi-scm-log>
]]>
</sub-log>
</multi-scm-log>

In this case, each log was blank, but you can see that the nested multi-scm-log's sub-log nodes have the ]]> encoded to &93;&93;&gt;. Before that, it will encode any "&" into "&amp;" – which means if it were nested even further, you would end up with "&amp;93&amp;93&amp;gt;". On the way out, I decode &amp; into &, and &93;&93;&gt; back into ]]>.

Now if I introduce an actual commit (e.g., if the commit contains "]]>" in the commit message), you can see how the nested encoding and decoding works:

<multi-scm-log version="2">
<sub-log scm="hudson.plugins.templateproject.ProxySCM">
<![CDATA[<multi-scm-log version="2">
<sub-log scm="hudson.plugins.git.GitSCM">
<![CDATA[Changes in branch origin/HEAD, between 8683af570511301fc8ea3ebeae3a8315f607bb63 and 8683af570511301fc8ea3ebeae3a8315f607bb63
Changes in branch origin/master, between 8683af570511301fc8ea3ebeae3a8315f607bb63 and 8683af570511301fc8ea3ebeae3a8315f607bb63
&93;&93;&gt;
</sub-log>
<sub-log scm="hudson.plugins.git.GitSCM">
<![CDATA[Changes in branch origin/master, between cd4b6a92715d10b63aa2f9d84101233034c20a85 and e3a66cdc1f8b3aac2ec585f1649d959482aecd11
commit e3a66cdc1f8b3aac2ec585f1649d959482aecd11
tree 6db2b3a0c13c04b459b5376c9aeb343edb09fb87
parent da5cb23b4e2989553fc14cdcf305595fcaa4820e
author Joe Hansche <jhans...@myyearbook.com> 1343852323 -0400
committer Joe Hansche <jhans...@myyearbook.com> 1343852323 -0400

    Testing 5 &amp;93;&amp;93;&amp;gt; x

:100644 100644 c9f2a7b2f5ea69d3eb178486fbe15c9757accbd6 097039f4f62342d3253b42297f19eb90aacb026f M	README

commit da5cb23b4e2989553fc14cdcf305595fcaa4820e
tree 9e004ae6f87c001f30c569feb1360eafb62cd3d4
parent cd4b6a92715d10b63aa2f9d84101233034c20a85
author Joe Hansche <jhans...@myyearbook.com> 1343851983 -0400
committer Joe Hansche <jhans...@myyearbook.com> 1343851983 -0400

    Testing 4 &amp;93;&amp;93;&amp;gt; x

:100644 100644 8e1178035834ac70cd49c258dbbe898d3badd476 c9f2a7b2f5ea69d3eb178486fbe15c9757accbd6 M	README
&93;&93;&gt;
</sub-log>
</multi-scm-log>
]]>
</sub-log>
</multi-scm-log>

And the changelog shows the expected "Testing 4 ]]> x"

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to