php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71595 NS end handler is never called
Submitted: 2016-02-15 02:38 UTC Modified: 2017-06-21 08:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: anrdaemon at freemail dot ru Assigned:
Status: Analyzed Package: XML related
PHP Version: 5.6.18 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-02-15 02:38 UTC] anrdaemon at freemail dot ru
Description:
------------
When NS-aware parser is created, the handler set by xml_set_end_namespace_decl_handler() is never called.

Test script:
---------------
<?php
$indent = '';
$parser = xml_parser_create_ns('UTF-8');

xml_set_end_namespace_decl_handler($parser, function($self, $name)
  {
    global $indent;
    $ns = $name ?: '(default)';
    print $indent . "/NS:{$ns}\n";
  });

// Expecting at least one mention of /NS: ...
xml_parse($parser, '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE shape PUBLIC "-//Dia//DTD Dia shape 1.0//EN" "http://www.daa.com.au/~james/dia-shape-ns">
<shape>
  <svg xmlns:svg="http://www.w3.org/2000/svg" svg:width="300px" svg:height="300px" svg:viewBox="0 0 3 3">
    <svg:circle svg:style="fill: yellow;" cx="1.5" cy="1.5" r="0.5"/>
  </svg>
</shape>', true);

print xml_error_string(xml_get_error_code($parser)) . "\n";
?>

Expected result:
----------------
Expecting at least one mention of "/NS:...".

Especially one, where parser leaving the enclosed SVG structure.

Actual result:
--------------
No error

(No really, there's no error. But... Where's my handlers?)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-16 16:08 UTC] ab@php.net
-Status: Open +Status: Analyzed
 [2016-02-16 16:08 UTC] ab@php.net
Thanks for the reports. How it looks like, the things you've realized do happen most likely not due to a PHP bug, but depend on the libxml2 usage. libxml doesn't support all the available callbacks, and it's documented. From a quick look, have to check deeper, the other tickets you've reported have the same cause. Many Linux distros link with libxml, as well it's used on Windows.

Thanks.
 [2016-02-16 17:59 UTC] anrdaemon at freemail dot ru
Do you think it deserves at least a note in documentation?
You know, it is rather frustrating to write a parser and find out that it just not supposed to work as documented.
 [2016-02-16 20:53 UTC] ab@php.net
-Type: Bug +Type: Documentation Problem
 [2016-02-16 20:53 UTC] ab@php.net
Yeah, clear the documentation could and should be improved. However, with this particular ticket, it's documented http://php.net/xml_set_end_namespace_decl_handler , please consider the note on the page:

This event is not supported under LibXML.

Maybe it's not synced with all the available languages, but actually i see that many contain it. What is not documented and I think it's hard to document, is what library is actually used with any particular build in a particular binary distribution. Right now, besides Windows builds at least Debian and Fedora use libxml instead of libxpat, for what i've checked. The main reason I think is that libxml is being supported and updated much more frequently. This info can be however gathered on the corresponding package pages of the respective distributions.

The other three tickets reported by you (just decrementing this ticked number :) need to be checked thoroughly as well, but how it reads from the code snippets and from the code base - the cause seems to be the same. So for now I'm turning this ticket into the documentation issue, lets see with the others.

Thanks.
 [2016-02-16 22:16 UTC] anrdaemon at freemail dot ru
Thanks, I've apparently missed that one note.
Should probably be a warning, and way up on the page, as it would be an impediment on most platforms.
 [2016-07-22 12:45 UTC] rasmus at mindplay dot dk
This should be considered a bug.

The fact that an XML parser API happens to be implemented by library that doesn't work predictably, is an implementation detail - it shouldn't mean that we offer an unpredictable/broken feature in PHP.

I just wasted like half a day before realizing that this function simply doesn't work and just silently fails. (under PHP 7 on Windows)

I then spent several more hours implementing support for xmlns-attributes myself, which was pretty difficult to get right - I suppose everyone who needs xmlns-support has to roll their own, and I'm sure many will get it wrong.

Beyond that, it's hard to imagine how someone managed to even make this feature platform-dependent in the first place?

Either way, having this one feature in an otherwise functional API that just quietly fails, is in my opinion completely unacceptable.
 [2016-09-29 06:25 UTC] fashionretailshop01 at gmail dot com
http://www.cheapjerseysfree.us/ - wholesale nfl jerseys
http://www.wholesalerjersey.com/ - wholesale jerseys
http://www.wholesaleCheapJerseysshipping.com/ - wholesale Jerseys free shipping
http://www.cheapwholesalejerseysshipping.com/ - cheap jerseys free shipping
http://www.wholesalejerseyscheapforsale.com/ - wholesale jers
 [2016-09-29 06:26 UTC] fashionretailshop01 at gmail dot com
http://www.cheapjerseyswholesaleforsale.com/ - cheap jerseys
http://www.WholesaleJerseysCheaponline.com/ - Wholesale Jerseys
http://www.wholesalejerseyscheapfromchina.com/ - wholesale jerseys from china
http://www.wholesalecheapauthenticjerseys.com/ - wholesale authentic jerseys
http://www.cheapauthenticwholesalejerseys.com/ - cheap authentic jerseys
 [2016-09-29 06:26 UTC] fashionretailshop01 at gmail dot com
http://www.about-jerseys.com/ - wholesale jerseys
http://www.about-jerseys.com/default.aspx/Sitemap - Cheap Jerseys - Wholesale Jerseys
http://www.fakesunglasseswholesale.com/ - sunglasses
http://www.fakesunglasseswholesale.com/tag.php?Cheap_Ray_Ban_Sunglasses/ - Cheap Ray Ban Sunglasses
http://www.fakesunglasseswholesale.com/news.php?cheap_oakleys_holbrook_sunglasses/ - cheap oakley holbrook sunglasses
 [2016-09-29 06:27 UTC] fashionretailshop01 at gmail dot com
http://www.wholesalediscountjerseys.com/AuthenticJerseys/ - Authentic NFL Jerseys
http://www.cheapjerseyswhoesale.com/ - About Jerseys News
http://www.cheapshoesfreeshipping.com/ - Best Shoes news Website
http://www.cheapsunglassesfreeshipping.com/ - Fashion Sunglasses News Website
http://www.sphoter.com/ - Buy Wholesale Cheap Free Shipping China
 [2016-09-29 06:28 UTC] fashionretailshop01 at gmail dot com
http://www.gryfino.sr.gov.pl/discount/nhl-jerseys/ - nhl jerseys
http://www.gryfino.sr.gov.pl/discount/nike-nfl-jerseys/ - nike nfl jerseys
http://www.gryfino.sr.gov.pl/discount/soccer-jerseys/ - soccer jerseys
 [2017-01-08 18:41 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=341634
Log: Fix #71595: NS end handler is never called
 [2017-01-08 18:50 UTC] cmb@php.net
-Type: Documentation Problem +Type: Bug -Assigned To: +Assigned To: cmb
 [2017-01-08 18:50 UTC] cmb@php.net
Even though bug #30834 has been closed as "won't fix", IMHO, this
is not just a documentation issue. Either
xml_set_end_namespace_decl_handler() shouldn't be defined, if it
is not supported by the underlying library, or it should at least
trigger a warning when called. For backwards compatibility the
latter appears to be more appropriate.

BTW, can somebody please kill the spam posts above?
 [2017-06-21 08:34 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC