|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
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.
$ctx->xpath_register_ns ("pre", '');

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:
$s = '<?xml version="1.0" ?>';
$s .= '<test:foo xmlns:test="">';
$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", '');
$p = xpath_eval($ctx_p, '/test:foo/test:bar');

$uri=""; //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.
$q: XPathObject Object
    [type] => 1
    [nodeset] => Array
            [0] => domelement Object
                    [type] => 1
                    [tagname] => bar
                    [0] => 5
                    [1] => 136278112




Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-08 05:14 UTC]
Works for me with:

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

 [2003-10-08 06:08 UTC]
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 
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]
Can you try with a more recent libxml2 version?

 [2003-10-13 03:03 UTC]
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]
Apprently libxml bug that is fixed in later versions.
-> bogus.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jan 17 04:01:23 2021 UTC