Auth_OpenID_Parse Class Reference
List of all members.
Detailed Description
This module implements a VERY limited parser that finds <link> tags in the head of HTML or XHTML documents and parses out their attributes according to the OpenID spec. It is a liberal parser, but it requires these things from the data in order to work:
- There must be an open <html> tag
- There must be an open <head> tag inside of the <html> tag
- Only <link>s that are found inside of the <head> tag are parsed (this is by design)
- The parser follows the OpenID specification in resolving the attributes of the link tags. This means that the attributes DO NOT get resolved as they would by an XML or HTML parser. In particular, only certain entities get replaced, and href attributes do not get resolved relative to a base URL.
From http://openid.net/specs.bml:
- The openid.server URL MUST be an absolute URL. OpenID consumers MUST NOT attempt to resolve relative URLs.
- The openid.server URL MUST NOT include entities other than &, <, >, and ".
The parser ignores SGML comments and <![CDATA[blocks]]>. Both kinds of quoting are allowed for attributes.
The parser deals with invalid markup in these ways:
- Tag names are not case-sensitive
- The <html> tag is accepted even when it is not at the top level
- The <head> tag is accepted even when it is not a direct child of the <html> tag, but a <html> tag must be an ancestor of the <head> tag
- <link> tags are accepted even when they are not direct children of the <head> tag, but a <head> tag must be an ancestor of the <link> tag
- If there is no closing tag for an open <html> or <head> tag, the remainder of the document is viewed as being inside of the tag. If there is no closing tag for a <link> tag, the link tag is treated as a short tag. Exceptions to this rule are that <html> closes <html> and <body> or <head> closes <head>
- Attributes of the <link> tag are not required to be quoted.
- In the case of duplicated attribute names, the attribute coming last in the tag will be the value returned.
- Any text that does not parse as an attribute within a link tag will be ignored. (e.g. <link pumpkin="" rel="openid.server"> will ignore pumpkin)
- If there are more than one <html> or <head> tag, the parser only looks inside of the first one.
- The contents of <script> tags are ignored entirely, except unclosed <script> tags. Unclosed <script> tags are ignored.
- Any other invalid markup is ignored, including unclosed SGML comments and unclosed <![CDATA[blocks.
PHP versions 4 and 5
LICENSE: See the COPYING file included in this distribution.
private
- Author:
- JanRain, Inc. <[email protected]> 2005-2008 Janrain, Inc. http://www.apache.org/licenses/LICENSE-2.0 Apache Require Auth_OpenID.arrayGet().
Definition at line 87 of file Parse.php.
Member Function Documentation
Auth_OpenID_Parse.Auth_OpenID_Parse |
( |
|
) |
|
Auth_OpenID_Parse.tagMatcher |
( |
$ |
tag_name, |
|
|
$ |
close_tags = null | |
|
) |
| | |
Returns a regular expression that will match a given tag in an SGML string.
Definition at line 140 of file Parse.php.
Auth_OpenID_Parse.openTag |
( |
$ |
tag_name |
) |
|
Auth_OpenID_Parse.closeTag |
( |
$ |
tag_name |
) |
|
Auth_OpenID_Parse.htmlBegin |
( |
$ |
s |
) |
|
Auth_OpenID_Parse.htmlEnd |
( |
$ |
s |
) |
|
Auth_OpenID_Parse.headFind |
( |
|
) |
|
Auth_OpenID_Parse.replaceEntities |
( |
$ |
str |
) |
|
Auth_OpenID_Parse.removeQuotes |
( |
$ |
str |
) |
|
Auth_OpenID_Parse.parseLinkAttrs |
( |
$ |
html |
) |
|
Find all link tags in a string representing a HTML document and return a list of their attributes.
- Parameters:
-
| string | $html The text to parse |
- Returns:
- array $list An array of arrays of attributes, one for each link tag
Definition at line 227 of file Parse.php.
Auth_OpenID_Parse.relMatches |
( |
$ |
rel_attr, |
|
|
$ |
target_rel | |
|
) |
| | |
Auth_OpenID_Parse.linkHasRel |
( |
$ |
link_attrs, |
|
|
$ |
target_rel | |
|
) |
| | |
Auth_OpenID_Parse.findLinksRel |
( |
$ |
link_attrs_list, |
|
|
$ |
target_rel | |
|
) |
| | |
Auth_OpenID_Parse.findFirstHref |
( |
$ |
link_attrs_list, |
|
|
$ |
target_rel | |
|
) |
| | |
Member Data Documentation
Auth_OpenID_Parse.$_re_flags = "si" |
Specify some flags for use with regex matching.
Definition at line 92 of file Parse.php.
Auth_OpenID_Parse.$_removed_re |
Initial value:
"<!--.*?-->|<!\[CDATA\[.*?\]\]>|<script\b(?!:)[^>]*>.*?<\/script>"
Stuff to remove before we start looking for tags
Definition at line 97 of file Parse.php.
Auth_OpenID_Parse.$_tag_expr = "<%s\b(?!:)([^>]*?)(?:\/>|>(.*?)(?:<\/?%s\s*>|\Z))" |
Starts with the tag name at a word boundary, where the tag name is not a namespace
Definition at line 104 of file Parse.php.
Auth_OpenID_Parse.$_attr_find = '\b(\w+)=("[^"]*"|\'[^\']*\'|[^\'"\s\/<>]+)' |
Auth_OpenID_Parse.$_open_tag_expr = "<%s\b" |
Auth_OpenID_Parse.$_close_tag_expr = "<((\/%s\b)|(%s[^>\/]*\/))>" |
The documentation for this class was generated from the following file: