function Auth_OpenID_remove_dot_segments($path)
{
    $result_segments = array();
    while ($path) {
        if (Auth_Yadis_startswith($path, '../')) {
            $path = substr($path, 3);
        } else {
            if (Auth_Yadis_startswith($path, './')) {
                $path = substr($path, 2);
            } else {
                if (Auth_Yadis_startswith($path, '/./')) {
                    $path = substr($path, 2);
                } else {
                    if ($path == '/.') {
                        $path = '/';
                    } else {
                        if (Auth_Yadis_startswith($path, '/../')) {
                            $path = substr($path, 3);
                            if ($result_segments) {
                                array_pop($result_segments);
                            }
                        } else {
                            if ($path == '/..') {
                                $path = '/';
                                if ($result_segments) {
                                    array_pop($result_segments);
                                }
                            } else {
                                if ($path == '..' || $path == '.') {
                                    $path = '';
                                } else {
                                    $i = 0;
                                    if ($path[0] == '/') {
                                        $i = 1;
                                    }
                                    $i = strpos($path, '/', $i);
                                    if ($i === false) {
                                        $i = strlen($path);
                                    }
                                    $result_segments[] = substr($path, 0, $i);
                                    $path = substr($path, $i);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return implode('', $result_segments);
}
Esempio n. 2
0
File: XRI.php Progetto: Blu2z/implsk
function Auth_Yadis_XRI($xri)
{
    if (!Auth_Yadis_startswith($xri, 'xri://')) {
        $xri = 'xri://' . $xri;
    }
    return $xri;
}
 function fetch($url, $body = null, $headers = null)
 {
     $this->fetchlog[] = array($url, $body, $headers);
     $u = parse_url($url);
     $proxy_host = $u['host'];
     $xri = $u['path'];
     $query = Auth_OpenID::arrayGet($u, 'query');
     if (!$headers && !$query) {
         trigger_error('Error in mock XRI fetcher: no headers or query');
     }
     if (Auth_Yadis_startswith($xri, '/')) {
         $xri = substr($xri, 1);
     }
     if (array_key_exists($xri, $this->documents)) {
         list($ctype, $body) = $this->documents[$xri];
         $status = 200;
     } else {
         $status = 404;
         $ctype = 'text/plain';
         $body = '';
     }
     return new Auth_Yadis_HTTPResponse($url, $status, array('content-type' => $ctype), $body);
 }