php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25775 Problem with uri-string in function xpath_register_ns()
Submitted: 2003-10-07 06:16 UTC Modified: 2003-10-13 03:39 UTC
From: thomas dot sattler at decon-network dot de Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.3.3 OS: Linux
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: thomas dot sattler at decon-network dot de
New email:
PHP Version: OS:

 

 [2003-10-07 06:16 UTC] thomas dot sattler at decon-network dot de
Description:
------------
If you whrite a string like "http://..." or 'http://...' into the xpath_register_ns function there will occur a problem with a stringlength between 16 and 23 characters and also between 40 and 47 characters.
Example:
$ctx->xpath_register_ns ("pre", 'http://www.xyz.de/');

The result is the same when the registered uri differs from the uri in the XML-file: 
There is no result object if evaluate an xpath with the registered namespace (like "/pre:foo").

If you define the uri in a variable (i.e. $uri) and write the xpath_register_ns() function with all is fine.

Reproduce code:
---------------
<?PHP
$s = '<?xml version="1.0" ?>';
$s .= '<test:foo xmlns:test="http://www.xyz.de/abc.xyz">';
$s .= '<test:bar>abc';
$s .= '</test:bar>';
$s .= '</test:foo>';
// namespace uri as string
$doc = domxml_open_mem($s); 
$ctx_p = xpath_new_context($doc);
$reg_succ_p = $ctx_p->xpath_register_ns ("test", 'http://www.xyz.de/abc.xyz');
$p = xpath_eval($ctx_p, '/test:foo/test:bar');

$uri="http://www.xyz.de/abc.xyz"; //namespace uri in $uri
$ctx_q = xpath_new_context($doc);
$reg_succ_q = $ctx_q->xpath_register_ns("test", $uri);
$q = xpath_eval($ctx_q, '/test:foo/test:bar');

echo '<PRE><br>$p: ';    print_r($p);
echo '<br>$q: ';    print_r($q);
echo "</PRE>";
?>

Expected result:
----------------
Both xpath_eval commands shood produce the same result:

The expected output is:

$p: XPathObject Object
(
    [type] => 1
    [nodeset] => Array
        (
            [0] => domelement Object
                (
                    [type] => 1
                    [tagname] => bar
                    [0] => 4
                    [1] => 135761016
                )

        )

)
$q: XPathObject Object
(
    [type] => 1
    [nodeset] => Array
        (
            [0] => domelement Object
                (
                    [type] => 1
                    [tagname] => bar
                    [0] => 4
                    [1] => 135761016
                )

        )

)


Actual result:
--------------
Only the second xpath evaluation where the registered uri is given as variable ($uri) is successful.
$p: 
$q: XPathObject Object
(
    [type] => 1
    [nodeset] => Array
        (
            [0] => domelement Object
                (
                    [type] => 1
                    [tagname] => bar
                    [0] => 5
                    [1] => 136278112
                )

        )

)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-08 05:14 UTC] chregu@php.net
Works for me with:

PHP 4.3.4-dev (cli) on Linux
and
PHP 4.3.2-RC3-dev (cli) on OS X

chregu
 [2003-10-08 06:08 UTC] sniper@php.net
Propably should ask what libxml version is used?

 [2003-10-08 06:26 UTC] thomas dot sattler at decon-network dot de
The Version of libxml is: 2.4.23 (20423)
DOM/XML API Version is: 20020815 
System:
Linux <servername> 2.4.19-64GB-SMP #1 SMP Mon Aug 4 23:48:22 UTC 2003 i686

It's interesting too that there occurs no error message and the value of the namespace register variable 
$reg_succ_p is 1 (I think this means success).

Finally: with PHP version 4.2.2 the problem didn't appear.
 [2003-10-08 07:20 UTC] chregu@php.net
Can you try with a more recent libxml2 version?



 [2003-10-13 03:03 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-10-13 03:35 UTC] thomas dot sattler at decon-network dot de
On the linux server we can't try another libxml2 version. We use the work around to define the uri string in a variable.
With PHP 4.3.3 on windows with libxml2 2.4.30 there is no bug (libxslt 1.0.23 compiled against libxml2 2.4.28). 
I would try with the same libxml2 version as on linux, but I don't know where to find libxml2 2.4.23 for windows.
 [2003-10-13 03:39 UTC] sniper@php.net
Apprently libxml bug that is fixed in later versions.
-> bogus.

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 18:01:23 2020 UTC