diff options
author | tailor <cygnus@janrain.com> | 2006-01-11 00:17:07 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2006-01-11 00:17:07 +0000 |
commit | a76173bfb4a8e1d5d44fe314bff63089fbb6d3dc (patch) | |
tree | 217cb48e87e64a269199532cc05adca1aabb384a | |
parent | 8476c7bcf83503dd5eed377243b8c2bf91df3c0e (diff) | |
download | php-openid-a76173bfb4a8e1d5d44fe314bff63089fbb6d3dc.zip php-openid-a76173bfb4a8e1d5d44fe314bff63089fbb6d3dc.tar.gz php-openid-a76173bfb4a8e1d5d44fe314bff63089fbb6d3dc.tar.bz2 |
[project @ Added base parse implementation]
-rw-r--r-- | Net/OpenID/Consumer/Parse.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Net/OpenID/Consumer/Parse.php b/Net/OpenID/Consumer/Parse.php index b24b9bc..ee9fa75 100644 --- a/Net/OpenID/Consumer/Parse.php +++ b/Net/OpenID/Consumer/Parse.php @@ -15,4 +15,62 @@ * @license http://www.gnu.org/copyleft/lesser.html LGPL */ +/** + * Specify some flags for use with regex matching. + */ +$_Net_OpenID_re_flags = "si"; + +// Stuff to remove before we start looking for tags +$_Net_OpenID_removed_re = "<!--.*?-->|" . + "<!\[CDATA\[.*?\]\]>|" . + "<script\b(?!:)[^>]*>.*?</script>"; + +// Starts with the tag name at a word boundary, where the tag name is +// not a namespace +$_Net_OpenID_tag_expr = "<%s\b(?!:)([^>]*?)" . + "(?:/>|>(.*?)" . + "(?:</?%s\s*>|\Z))"; + +function Net_OpenID_tagMatcher($tag_name, $close_tags = null) +{ + global $_Net_OpenID_tag_expr, $_Net_OpenID_re_flags; + + if ($close_tags) { + $options = implode("|", array_merge(array($tag_name), $close_tags)); + $closer = sprintf("(?:%s)", $options); + } else { + $closer = $tag_name; + } + + $expr = sprintf($_Net_OpenID_tag_expr, $tag_name, $closer); + return sprintf("/%s/%s", $expr, $_Net_OpenID_re_flags); +} + +function Net_OpenID_html_find() +{ + return Net_OpenID_tagMatcher('html'); +} + +function Net_OpenID_head_find() +{ + return Net_OpenID_tagMatcher('head'); +} + +$_Net_OpenID_link_find = sprintf("/<link\b(?!:)/%s", $_Net_OpenID_re_flags); + +$_Net_OpenID_attr_find = "(\w+)=(?:[\"'](.*?)\\1|(?:[^\s<>/]|/(?!>))+)|[<>]/"; +$_Net_OpenID_attr_find = sprintf("/%s/%s", $_Net_OpenID_attr_find, + $_Net_OpenID_re_flags); + +$_Net_OpenID_entity_replacements = array( + 'amp' => '&', + 'lt' => '<', + 'gt' => '>', + 'quot' => '"' + ); + +function Net_OpenID_entity_replace() +{ +} + ?>
\ No newline at end of file |