1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
"DTD/xhtml1-transitional.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<title>openid.consumer.html_parse</title>
7
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
9
<body bgcolor="white" text="black" link="blue" vlink="#204080"
12
<!-- =========== START OF NAVBAR =========== -->
13
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
15
<th class="navbar"> <a class="navbar" href="openid-module.html">Home</a> </th>
16
<th class="navbar"> <a class="navbar" href="trees.html">Trees</a> </th>
17
<th class="navbar"> <a class="navbar" href="indices.html">Index</a> </th>
18
<th class="navbar"> <a class="navbar" href="help.html">Help</a> </th>
19
<th class="navbar" align="right" width="100%">
20
<table border="0" cellpadding="0" cellspacing="0">
21
<tr><th class="navbar" align="center">
23
<a class="navbar" target="_top" href="http://www.openidenabled.com/">Python-OpenID</a>
24
</p></th></tr></table>
28
<table width="100%" cellpadding="0" cellspacing="0">
31
<font size="-1"><b class="breadcrumbs">
32
<a href="openid-module.html">Package openid</a> ::
33
<a href="openid.consumer-module.html">Package consumer</a> ::
34
Module html_parse
37
<td><table cellpadding="0" cellspacing="0">
38
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a> | <a href="openid.consumer.html_parse-module.html" target="_top">no frames</a>]</font></td></tr>
42
<!-- =========== START OF MODULE DESCRIPTION =========== -->
43
<h2 class="module">Module openid.consumer.html_parse</h2>
45
This module implements a VERY limited parser that finds <link>
46
tags in the head of HTML or XHTML documents and parses out their
47
attributes according to the OpenID spec. It is a liberal parser, but it
48
requires these things from the data in order to work:
51
There must be an open <html> tag
54
There must be an open <head> tag inside of the <html>
58
Only <link>s that are found inside of the <head> tag
59
are parsed (this is by design)
62
The parser follows the OpenID specification in resolving the
63
attributes of the link tags. This means that the attributes DO NOT
64
get resolved as they would by an XML or HTML parser. In particular,
65
only certain entities get replaced, and href attributes do not get
66
resolved relative to a base URL.
69
From http://openid.net/specs.bml#linkrel:
72
The openid.server URL MUST be an absolute URL. OpenID consumers
73
MUST NOT attempt to resolve relative URLs.
76
The openid.server URL MUST NOT include entities other than
77
&amp;, &lt;, &gt;, and &quot;.
80
<p>The parser ignores SGML comments and <![CDATA[blocks]]>. Both
81
kinds of quoting are allowed for attributes.</p>
82
The parser deals with invalid markup in these ways:
85
Tag names are not case-sensitive
88
The <html> tag is accepted even when it is not at the top
92
The <head> tag is accepted even when it is not a direct
93
child of the <html> tag, but a <html> tag must be an
94
ancestor of the <head> tag
97
<link> tags are accepted even when they are not direct
98
children of the <head> tag, but a <head> tag must be an
99
ancestor of the <link> tag
102
If there is no closing tag for an open <html> or
103
<head> tag, the remainder of the document is viewed as being
104
inside of the tag. If there is no closing tag for a <link> tag,
105
the link tag is treated as a short tag. Exceptions to this rule are
106
that <html> closes <html> and <body> or
107
<head> closes <head>
110
Attributes of the <link> tag are not required to be
114
In the case of duplicated attribute names, the attribute coming
115
last in the tag will be the value returned.
118
Any text that does not parse as an attribute within a link tag
119
will be ignored. (e.g. <link pumpkin rel='openid.server' />
123
If there are more than one <html> or <head> tag, the
124
parser only looks inside of the first one.
127
The contents of <script> tags are ignored entirely, except
128
unclosed <script> tags. Unclosed <script> tags are
132
Any other invalid markup is ignored, including unclosed SGML
133
comments and unclosed <![CDATA[blocks.
138
<!-- =========== START OF FUNCTION SUMMARY =========== -->
139
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
140
<tr bgcolor="#70b0f0" class="summary">
141
<th colspan="2">Function Summary</th></tr>
142
<tr><td align="right" valign="top" width="15%"><font size="-1"> [[(type(html), type(html))]]
144
<td><code><span class="summary-sig"><a href="openid.consumer.html_parse-module.html#parseLinkAttrs" class="summary-sig-name"><code>parseLinkAttrs</code></a>(<span class=summary-sig-arg>html</span>)</span></code>
146
Find all link tags in a string representing a HTML document and return
147
a list of their attributes.</td></tr>
151
<!-- =========== START OF FUNCTION DETAILS =========== -->
152
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
153
<tr bgcolor="#70b0f0" class="details">
154
<th colspan="2">Function Details</th></tr>
157
<a name="parseLinkAttrs"></a>
158
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
159
<h3><span class="sig"><span class="sig-name">parseLinkAttrs</span>(<span class=sig-arg>html</span>)</span>
161
Find all link tags in a string representing a HTML document and
162
return a list of their attributes.
164
<dl><dt><b>Parameters:</b></dt>
165
<dd><code><b>html</b></code> -
167
<br /><i>
168
(type=str or unicode)</i>
171
<dl><dt><b>Returns:</b></dt>
173
A list of dictionaries of attributes, one for each link
175
<br /><i>
176
(type=[[(type(html), type(html))]])</i>
184
<!-- =========== START OF NAVBAR =========== -->
185
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
187
<th class="navbar"> <a class="navbar" href="openid-module.html">Home</a> </th>
188
<th class="navbar"> <a class="navbar" href="trees.html">Trees</a> </th>
189
<th class="navbar"> <a class="navbar" href="indices.html">Index</a> </th>
190
<th class="navbar"> <a class="navbar" href="help.html">Help</a> </th>
191
<th class="navbar" align="right" width="100%">
192
<table border="0" cellpadding="0" cellspacing="0">
193
<tr><th class="navbar" align="center">
195
<a class="navbar" target="_top" href="http://www.openidenabled.com/">Python-OpenID</a>
196
</p></th></tr></table>
201
<table border="0" cellpadding="0" cellspacing="0" width="100%">
203
<td align="left"><font size="-2">Generated by Epydoc 2.1 on Mon Sep 10 13:00:12 2007</font></td>
204
<td align="right"><a href="http://epydoc.sourceforge.net"
205
><font size="-2">http://epydoc.sf.net</font></a></td>