Page MenuHomePhorge

include Outlook 2010 XML Namespace in XML parser
ClosedPublic

Authored by stephanh on Aug 4 2015, 12:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 12:06 PM
Unknown Object (File)
Sat, Apr 13, 11:44 PM
Unknown Object (File)
Wed, Apr 10, 4:49 AM
Unknown Object (File)
Sat, Apr 6, 6:53 PM
Unknown Object (File)
Sat, Apr 6, 11:18 AM
Unknown Object (File)
Wed, Mar 27, 8:38 AM
Unknown Object (File)
Wed, Mar 27, 8:38 AM
Unknown Object (File)
Wed, Mar 27, 8:23 AM
Subscribers
None

Details

Reviewers
machniak
Group Reviewers
Autoconf Developers
Summary

AutodiscoverMicrosoft.php doesn't check for a namespace.

the xml request looks like this

[04-Aug-2015 10:56:48 +0200]: [DEBUG] Request [microsoft]:

<?xml version="1.0" encoding="utf-8"?><Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>test.test@test.net</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>

the email field is always empty after parsing the request.

FIX
''''''''
Replace Namestring in Request

Test Plan

simple php file with xmlParser

<?php
$strXml= <<<XML
<?xml version="1.0" encoding="utf-8"?><Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"><Request><EMailAddress>test.test@test.net</EMailAddress><AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema></Request></Autodiscover>
XML;

$xmlDoc=new \SimpleXMLElement($strXml);

foreach($xmlDoc->getDocNamespaces() as $strPrefix => $strNamespace) {

if(strlen($strPrefix)==0) {
    $strPrefix="a"; //Assign an arbitrary namespace prefix.
}
$xmlDoc->registerXPathNamespace($strPrefix,$strNamespace);

}

print($xmlDoc->xpath("a:EMailAddress")[0]); Use the arbitrary namespace prefix in the query.
?>

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

stephanh retitled this revision from to include Outlook 2010 XML Namespace in XML parser .
stephanh updated this object.
stephanh edited the test plan for this revision. (Show Details)
stephanh added a reviewer: Autoconf Developers.
stephanh set the repository for this revision to rAC autoconf.
stephanh removed rAC autoconf as the repository for this revision.

updated indentation

This revision is now accepted and ready to land.Feb 8 2016, 1:46 PM

Thank you for the patch. I pushed slightly cleaned up version.