<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Brad,</p>
<p>yes you're right. A 19-year old bug now gone in
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/pull/13450">https://github.com/OSGeo/gdal/pull/13450</a>. Perhaps the erroneous
addition of the NUL byte was to imitate oldish Kakadu version
since the jpylyzer manual mentions that about their 'nullbyte'
option?</p>
<p>Even</p>
<div class="moz-cite-prefix">Le 20/11/2025 à 01:56, Brad Hards via
gdal-dev a écrit :<br>
</div>
<blockquote type="cite" cite="mid:5066187.GXAFRqVoOG@audax">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">It
looks like there is a trailing null in the character data
written inside the XML box in JPEG 2000 (only tested with
OpenJPEG). </p>
<br>
<p
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I'm
seeing a validation error in jpylyzer about not well formed XML,
which I think is probably related to this. Or at least goes away
with this change:</p>
<br>
<p
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span
style="color:#000000;"><span style="background-color:#ffffff;"><strong><span
style="font-family:monospace;">diff --git
a/gcore/gdaljp2metadata.cpp b/gcore/gdaljp2metadata.cpp</span></strong> </span></span><br>
<span style="color:#000000;"><span
style="background-color:#ffffff;"><strong>index
439b7e6625..a247cad9f8 100644</strong> </span></span><br>
<span style="color:#000000;"><span
style="background-color:#ffffff;"><strong>---
a/gcore/gdaljp2metadata.cpp</strong> </span></span><br>
<span style="color:#000000;"><span
style="background-color:#ffffff;"><strong>+++
b/gcore/gdaljp2metadata.cpp</strong> </span></span><br>
<span style="background-color:#ffffff;"><span
style="color:#18b2b2;">@@ -3333,7 +3333,7 @@</span><span
style="color:#000000;"> <a class="moz-txt-link-freetext" href="GDALJP2Metadata::CreateGDALMultiDomainMetadataXMLBox(GDALDataset">GDALJP2Metadata::CreateGDALMultiDomainMetadataXMLBox(GDALDataset</a>
*poSrcDS, </span></span><br>
<br>
GDALJP2Box *poBox = new GDALJP2Box(); <br>
poBox->SetType("xml "); <span
style="background-color:#ffffff;"><span style="color:#b21818;">-
poBox->SetWritableData(static_cast<int>(strlen(pszXML) + 1),</span><span
style="color:#000000;"> </span></span><br>
<span style="background-color:#ffffff;"><span
style="color:#18b218;">+
poBox->SetWritableData(static_cast<int>(strlen(pszXML)),</span><span
style="color:#000000;"> </span></span><br>
reinterpret_cast<const GByte
*>(pszXML)); <br>
CPLFree(pszXML); <br>
</p>
<p
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">However
that +1 looks deliberate. So is that trailing null intentional,
in that its required for some interoperability or backwards
compatibility reason, even though it isn't strictly allowed in
XML?</p>
<br>
<p
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Brad</p>
<br>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>