php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #76763 Make libxml_set_external_entity_loader() return previous entity loader
Submitted: 2018-08-18 10:14 UTC Modified: 2022-08-28 11:55 UTC
From: clicky at erebot dot net Assigned: bukka (profile)
Status: Closed Package: XML related
PHP Version: 7.2.9 OS: Debian 9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: clicky at erebot dot net
New email:
PHP Version: OS:

 

 [2018-08-18 10:14 UTC] clicky at erebot dot net
Description:
------------
There is no way at the moment to retrieve the callback currently in use by libxml2's entity loader.

Imagine an application uses XML and has defined an entity loader.
Now, that application relies on an external library which also uses XML and relies on its own entity loader.

When the library is called, it will overwrite the application's entity loader with no way to restore it afterward.

I suggest changing the return value of libxml_set_external_entity_loader() so that it returns the previous entity loader if one was registered or NULL if no entity loader has been registered yet. It would also return NULL for errors.
This would match the behavior of other PHP functions like set_error_handler() and set_exception_handler().

Alternatively, being able to define multiple (stacking) entity loaders or having a function to restore the previous entity loader would be fine too.


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-19 14:19 UTC] cmb@php.net
That looks like a reasonable request.  A respective PR would
likely be welcome.

[1] <https://github.com/php/php-src/pulls>
 [2022-01-21 04:50 UTC] tstarling@php.net
The following pull request has been associated:

Patch Name: Make libxml_set_external_entity_loader() return the previous loader
On GitHub:  https://github.com/php/php-src/pull/7977
Patch:      https://github.com/php/php-src/pull/7977.patch
 [2022-08-28 11:55 UTC] bukka@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: bukka
 [2022-08-28 11:55 UTC] bukka@php.net
The mentioned PR has been merged so closing this.
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Jan 29 06:05:52 2023 UTC