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: -
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: lstrojny@php.net Assigned:
Status: Open Package: solr (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lstrojny@php.net
New email:
PHP Version: OS:

 

 [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

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 19:01:29 2024 UTC