diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-03-22 18:48:20 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-03-22 18:48:20 +0000 |
commit | e8d18e41fc25af8dad5746e5b3bd6982c2492c2e (patch) | |
tree | ea2f2bf94b63828003376e9d4ad3c5e18a27e474 /modules/openid/xrds.inc | |
parent | 2598778efa1887a4f2a8eb016114d32e8b6259a8 (diff) | |
download | brdo-e8d18e41fc25af8dad5746e5b3bd6982c2492c2e.tar.gz brdo-e8d18e41fc25af8dad5746e5b3bd6982c2492c2e.tar.bz2 |
- Patch #218097 by c960657: OpenID must use canonical ID when authenticating XRI i-names.
Diffstat (limited to 'modules/openid/xrds.inc')
-rw-r--r-- | modules/openid/xrds.inc | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/modules/openid/xrds.inc b/modules/openid/xrds.inc deleted file mode 100644 index 6e05d0c09..000000000 --- a/modules/openid/xrds.inc +++ /dev/null @@ -1,90 +0,0 @@ -<?php -// $Id$ - -// Global variables to track parsing state -$xrds_open_elements = array(); -$xrds_services = array(); -$xrds_current_service = array(); - -/** - * Main entry point for parsing XRDS documents - */ -function xrds_parse($xml) { - global $xrds_services; - - $parser = xml_parser_create_ns(); - xml_set_element_handler($parser, '_xrds_element_start', '_xrds_element_end'); - xml_set_character_data_handler($parser, '_xrds_cdata'); - - xml_parse($parser, $xml); - xml_parser_free($parser); - - return $xrds_services; -} - -/** - * Parser callback functions - */ -function _xrds_element_start(&$parser, $name, $attributes) { - global $xrds_open_elements, $xrds_current_service; - - $xrds_open_elements[] = _xrds_strip_namespace($name); - - $path = strtoupper(implode('/', $xrds_open_elements)); - if ($path == 'XRDS/XRD/SERVICE') { - foreach ($attributes as $attribute_name => $value) { - if (_xrds_strip_namespace($attribute_name) == 'PRIORITY') { - $xrds_current_service['priority'] = intval($value); - } - } - } -} - -function _xrds_element_end(&$parser, $name) { - global $xrds_open_elements, $xrds_services, $xrds_current_service; - - $name = _xrds_strip_namespace($name); - if ($name == 'SERVICE') { - if (!isset($xrds_current_service['priority'])) { - // If the priority attribute is absent, the default is infinity. - $xrds_current_service['priority'] = PHP_INT_MAX; - } - $xrds_services[] = $xrds_current_service; - $xrds_current_service = array(); - } - array_pop($xrds_open_elements); -} - -function _xrds_cdata(&$parser, $data) { - global $xrds_open_elements, $xrds_services, $xrds_current_service; - $path = strtoupper(implode('/', $xrds_open_elements)); - switch ($path) { - case 'XRDS/XRD/SERVICE/TYPE': - $xrds_current_service['types'][] = $data; - break; - case 'XRDS/XRD/SERVICE/URI': - $xrds_current_service['uri'] = $data; - break; - case 'XRDS/XRD/SERVICE/DELEGATE': - $xrds_current_service['delegate'] = $data; - break; - case 'XRDS/XRD/SERVICE/LOCALID': - $xrds_current_service['localid'] = $data; - break; - default: - if (preg_match('@^XRDS/XRD/SERVICE/(.*)$@', $path, $matches)) { - $xrds_current_service['additional'][$matches[1]] = $data; - } - break; - } -} - -function _xrds_strip_namespace($name) { - // Strip namespacing. - $pos = strrpos($name, ':'); - if ($pos !== FALSE) { - $name = substr($name, $pos + 1, strlen($name)); - } - - return $name; -} |