function Auth_OpenID_urinorm($uri) { $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(); preg_match(Auth_OpenID_getURLIllegalCharRE(), $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(); preg_match(Auth_OpenID_getAuthorityPattern(), $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_getEncodedPattern(), '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_getEncodedPattern(), 'Auth_OpenID_pct_encoded_replace_unreserved', $path); $path = Auth_OpenID_remove_dot_segments($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; }
function getLegacyUserIDsFromOpenID($openid_identity) { // Issue 17515512: workaround $result = array(); $uri_matches = array(); preg_match(Auth_OpenID_getURIPattern(), $openid_identity, $uri_matches); if (count($uri_matches) < 9) { for ($i = count($uri_matches); $i <= 9; $i++) { $uri_matches[] = ''; } } $scheme = $uri_matches[2]; $authority = $uri_matches[4]; $path = $uri_matches[5]; $query = $uri_matches[6]; $fragment = $uri_matches[8]; if ($scheme === null) { $scheme = ''; } if ($authority === null) { $authority = ''; } if ($path === null) { $path = ''; } if ($query === null) { $query = ''; } if ($fragment === null) { $fragment = ''; } if ($scheme == 'http' or $scheme == '') { $scheme_part = ''; } else { $scheme_part = $scheme . "://"; } if ($path == '' || $path == '/') { $result[] = $scheme_part . $authority . '' . $query . $fragment; $result[] = $scheme_part . $authority . '/' . $query . $fragment; } else { $result[] = $scheme_part . $authority . $path . $query . $fragment; } return $result; }