ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
URINorm.php File Reference

Go to the source code of this file.

Namespaces

namespace  OpenID
 This module contains code for dealing with associations between consumers and servers.

Functions

 Auth_OpenID_getURIPattern ()
 Auth_OpenID_getAuthorityPattern ()
 Auth_OpenID_getEncodedPattern ()
 Auth_OpenID_getURLIllegalCharRE ()
 Auth_OpenID_getUnreserved ()
 Auth_OpenID_getEscapeRE ()
 Auth_OpenID_pct_encoded_replace_unreserved ($mo)
 Auth_OpenID_pct_encoded_replace ($mo)
 Auth_OpenID_remove_dot_segments ($path)
 Auth_OpenID_urinorm ($uri)

Function Documentation

Auth_OpenID_getAuthorityPattern ( )

Definition at line 20 of file URINorm.php.

Referenced by Auth_OpenID_urinorm().

{
return '/^([^@]*@)?([^:]*)(:.*)?/';
}

+ Here is the caller graph for this function:

Auth_OpenID_getEncodedPattern ( )

Definition at line 25 of file URINorm.php.

Referenced by Auth_OpenID_urinorm().

{
return '/%([0-9A-Fa-f]{2})/';
}

+ Here is the caller graph for this function:

Auth_OpenID_getEscapeRE ( )

Definition at line 68 of file URINorm.php.

References $n, Auth_Yadis_getIPrivateChars(), and Auth_Yadis_getUCSChars().

{
$parts = array();
foreach (array_merge(Auth_Yadis_getUCSChars(),
list($m, $n) = $pair;
$parts[] = sprintf("%s-%s", chr($m), chr($n));
}
return sprintf('[%s]', implode('', $parts));
}

+ Here is the call graph for this function:

Auth_OpenID_getUnreserved ( )

Definition at line 41 of file URINorm.php.

Referenced by Auth_OpenID_pct_encoded_replace_unreserved().

{
$_unreserved = array();
for ($i = 0; $i < 256; $i++) {
$_unreserved[$i] = false;
}
for ($i = ord('A'); $i <= ord('Z'); $i++) {
$_unreserved[$i] = true;
}
for ($i = ord('0'); $i <= ord('9'); $i++) {
$_unreserved[$i] = true;
}
for ($i = ord('a'); $i <= ord('z'); $i++) {
$_unreserved[$i] = true;
}
$_unreserved[ord('-')] = true;
$_unreserved[ord('.')] = true;
$_unreserved[ord('_')] = true;
$_unreserved[ord('~')] = true;
return $_unreserved;
}

+ Here is the caller graph for this function:

Auth_OpenID_getURIPattern ( )

Definition at line 15 of file URINorm.php.

Referenced by Auth_OpenID_urinorm().

{
return '&^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?&';
}

+ Here is the caller graph for this function:

Auth_OpenID_getURLIllegalCharRE ( )

Definition at line 36 of file URINorm.php.

Referenced by Auth_OpenID_urinorm().

{
return "/([^-A-Za-z0-9:\/\?#\[\]@\!\$&'\(\)\*\+,;=\._~\%])/";
}

+ Here is the caller graph for this function:

Auth_OpenID_pct_encoded_replace (   $mo)

Definition at line 94 of file URINorm.php.

{
return chr(intval($mo[1], 16));
}
Auth_OpenID_pct_encoded_replace_unreserved (   $mo)

Definition at line 80 of file URINorm.php.

References Auth_OpenID_getUnreserved().

{
$_unreserved = Auth_OpenID_getUnreserved();
$i = intval($mo[1], 16);
if ($_unreserved[$i]) {
return chr($i);
} else {
return strtoupper($mo[0]);
}
return $mo[0];
}

+ Here is the call graph for this function:

Auth_OpenID_remove_dot_segments (   $path)

Definition at line 99 of file URINorm.php.

References $path, and Auth_Yadis_startswith().

Referenced by Auth_OpenID_urinorm().

{
$result_segments = array();
while ($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);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_urinorm (   $uri)

Definition at line 142 of file URINorm.php.

References $path, $query, Auth_OpenID_getAuthorityPattern(), Auth_OpenID_getEncodedPattern(), Auth_OpenID_getURIPattern(), Auth_OpenID_getURLIllegalCharRE(), and Auth_OpenID_remove_dot_segments().

Referenced by Auth_OpenID_GenericConsumer\_checkReturnTo().

{
$uri_matches = array();
preg_match(Auth_OpenID_getURIPattern(), $uri, $uri_matches);
if (count($uri_matches) < 9) {
for ($i = count($uri_matches); $i <= 9; $i++) {
$uri_matches[] = '';
}
}
$illegal_matches = array();
$uri, $illegal_matches);
if ($illegal_matches) {
return null;
}
$scheme = $uri_matches[2];
if ($scheme) {
$scheme = strtolower($scheme);
}
$scheme = $uri_matches[2];
if ($scheme === '') {
// No scheme specified
return null;
}
$scheme = strtolower($scheme);
if (!in_array($scheme, array('http', 'https'))) {
// Not an absolute HTTP or HTTPS URI
return null;
}
$authority = $uri_matches[4];
if ($authority === '') {
// Not an absolute URI
return null;
}
$authority_matches = array();
$authority, $authority_matches);
if (count($authority_matches) === 0) {
// URI does not have a valid authority
return null;
}
if (count($authority_matches) < 4) {
for ($i = count($authority_matches); $i <= 4; $i++) {
$authority_matches[] = '';
}
}
list($_whole, $userinfo, $host, $port) = $authority_matches;
if ($userinfo === null) {
$userinfo = '';
}
if (strpos($host, '%') !== -1) {
$host = strtolower($host);
$host = preg_replace_callback(
'Auth_OpenID_pct_encoded_replace', $host);
// NO IDNA.
// $host = unicode($host, 'utf-8').encode('idna');
} else {
$host = strtolower($host);
}
if ($port) {
if (($port == ':') ||
($scheme == 'http' && $port == ':80') ||
($scheme == 'https' && $port == ':443')) {
$port = '';
}
} else {
$port = '';
}
$authority = $userinfo . $host . $port;
$path = $uri_matches[5];
$path = preg_replace_callback(
'Auth_OpenID_pct_encoded_replace_unreserved', $path);
if (!$path) {
$path = '/';
}
$query = $uri_matches[6];
if ($query === null) {
$query = '';
}
$fragment = $uri_matches[8];
if ($fragment === null) {
$fragment = '';
}
return $scheme . '://' . $authority . $path . $query . $fragment;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function: