php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76407 digestXmlResponse() fails to parse perfectly well formed XML responses
Submitted: 2018-06-02 22:02 UTC Modified: -
From: lstrojny@php.net Assigned:
Status: Open Package: solr (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-06-02 22:02 UTC] lstrojny@php.net
Description:
------------
SolrUtils::digestXmlResponse() fails to parse this response:

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <result name="response" numFound="7" start="0" maxScore="1.0">
        <doc><str name="foo">bar</str></doc>
    </result>
</response>


It will work for this response with a slight whitespace change:
<?xml version="1.0" encoding="UTF-8"?>
<response>
    <result name="response" numFound="7" start="0" maxScore="1.0">
        <doc> <str name="foo">bar</str></doc>
    </result>
</response>


This is the diff between the two responses:
$ diff -u fail.xml success.xml
--- fail.xml	2018-06-01 19:55:28.375146179 +0200
+++ success.xml	2018-06-01 19:55:57.128476904 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <response>
     <result name="response" numFound="7" start="0" maxScore="1.0">
-        <doc><str name="foo">bar</str></doc>
+        <doc> <str name="foo">bar</str></doc>
     </result>
 </response>


$ php repro.php

Notice: SolrUtils::digestXmlResponse(): Unexpected end of serialized data in /code/in/test.php on line 2

Warning: SolrUtils::digestXmlResponse(): Error unserializing raw response. in /code/in/test.php on line 2

Fatal error: Uncaught SolrException: Error un-serializing response in /code/in/test.php:2
Stack trace:
#0 /code/in/test.php(2): SolrUtils::digestXmlResponse('<?xml version="...')
#1 {main}
  thrown in /code/in/test.php on line 2

Test script:
---------------
<?php
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<response>
    <result name="response" numFound="7" start="0" maxScore="1.0">
        <doc><str name="foo">bar</str></doc>
    </result>
</response>';

SolrUtils::digestXmlResponse($xml);


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 15:01:27 2019 UTC