diff --git a/src/BeSimple/SoapClient/Xml/Path/RelativePathResolver.php b/src/BeSimple/SoapClient/Xml/Path/RelativePathResolver.php index 2417478..7d29221 100644 --- a/src/BeSimple/SoapClient/Xml/Path/RelativePathResolver.php +++ b/src/BeSimple/SoapClient/Xml/Path/RelativePathResolver.php @@ -19,16 +19,16 @@ class RelativePathResolver public function resolveRelativePathInUrl($base, $relative) { $urlParts = parse_url($base); - $isRelativePathAbsolute = 0 === strpos($relative, '/') || 0 === strpos($relative, '..'); + $pathIsSet = true === isset($urlParts['path']); // combine base path with relative path - if (isset($urlParts['path']) && mb_strlen($relative) > 0 && $isRelativePathAbsolute) { + if (true === $pathIsSet && 0 < mb_strlen($relative) && 0 === strpos($relative, '/')) { // $relative is absolute path from domain (starts with /) $path = $relative; - } elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']) )) { + } elseif (true === $pathIsSet && strrpos($urlParts['path'], '/') === strlen($urlParts['path'])) { // base path is directory $path = $urlParts['path'].$relative; - } elseif (isset($urlParts['path'])) { + } elseif (true === $pathIsSet) { // strip filename from base path $path = substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')).'/'.$relative; } else { diff --git a/tests/BeSimple/SoapClient/Xml/Path/RelativePathResolverTest.php b/tests/BeSimple/SoapClient/Xml/Path/RelativePathResolverTest.php index 728554e..07d487b 100644 --- a/tests/BeSimple/SoapClient/Xml/Path/RelativePathResolverTest.php +++ b/tests/BeSimple/SoapClient/Xml/Path/RelativePathResolverTest.php @@ -30,6 +30,11 @@ class RelativePathResolverTest extends PHPUnit_Framework_TestCase public function providePathInfo() { return [ + [ + 'http://anyendpoint.tld:9999/path/to/endpoint.wsdl', + '../Schemas/Common/SoapHeader.xsd', + 'http://anyendpoint.tld:9999/path/Schemas/Common/SoapHeader.xsd', + ], [ 'http://endpoint-location.ltd/', 'Document1.xsd',