- changed status to resolved
XML error in HTTP-POST from Monit to M/Monit
Hi,
I am working on a Python module that parses the XML of the HTTP-POST request from Monit to M/Monit. I noticed that the following statement in Monit's configuration will create invalid XML.
check host host.localhost with address 127.0.0.1
if failed port 80 protocol http
request "/data/show?a=b&c=d"
then alert
Resulting XML fragment
<port>
<hostname>127.0.0.1</hostname>
<portnumber>80</portnumber>
<request>/data/show?a=b&c=d</request>
<protocol>HTTP</protocol>
<type>TCP</type>
<responsetime>-1.000</responsetime>
</port>
And the XML parser error.
parser error : EntityRef: expecting ';' <request>/data/show?a=b&c
I believe the text inside the <request> node should be wrapped inside a CDATA section according to the XML specification (http://www.w3.org/TR/xml/, section 2.4 Character Data and Markup):
The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
I wonder whether other XML nodes may be affected, too. I noticed that the <event><message> node is already wrapepd into CDATA.
Thanks Markus
Comments (1)
-
repo owner - Log in to comment
Thank you for report, the problem is fixed now: https://bitbucket.org/tildeslash/monit/commits/8d345ffce56c/