Skip to content

Commit

Permalink
[giow] (1) Fix the handling of infinite loops in the various microdat…
Browse files Browse the repository at this point in the history
…a algorithms.

git-svn-id: http://svn.whatwg.org/webapps@6277 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jul 7, 2011
1 parent b1b4a62 commit d827034
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 266 deletions.
156 changes: 74 additions & 82 deletions complete.html
Expand Up @@ -239,7 +239,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1>Web Applications 1.0</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 1 July 2011</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 7 July 2011</h2>
</hgroup><dl><dt>Multiple-page version:</dt>
<dd><a href=http://www.whatwg.org/specs/web-apps/current-work/complete/>http://www.whatwg.org/specs/web-apps/current-work/complete/</a></dd>
<dt>One-page version:</dt>
Expand Down Expand Up @@ -56903,6 +56903,14 @@ <h4 id=items><span class=secno>5.2.2 </span>Items</h4>
<p>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute must not
be specified on elements that do not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified.</p>

<p class=note>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code>
attribute is not part of the microdata data model. It is merely a
syntactic construct to aid authors in adding annotations to pages
where the data to be annotated does not follow a convenient tree
structure. For example, it allows authors to mark up data in a table
so that each column defines a separate <a href=#concept-item title=concept-item>item</a>, while keeping the properties in
the cells.</p>


<h4 id=names:-the-itemprop-attribute><span class=secno>5.2.3 </span>Names: the <dfn title=attr-itemprop><code>itemprop</code></dfn> attribute</h4>

Expand Down Expand Up @@ -57092,52 +57100,15 @@ <h4 id=values><span class=secno>5.2.4 </span>Values</h4>
<h4 id=associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</h4>

<p>To find <dfn id=the-properties-of-an-item>the properties of an item</dfn> defined by the
element <var title="">root</var>, the user agent must try to
<a href=#crawl-the-properties>crawl the properties</a> of the element <var title="">root</var>, with an empty list as the value of <var title="">memory</var>: if this fails, then <a href=#the-properties-of-an-item title="the
properties of an item">the properties of the item</a> defined by
the element <var title="">root</var> is an empty list; otherwise, it
is the returned list.</p>

<p>To <dfn id=crawl-the-properties>crawl the properties</dfn> of an element <var title="">root</var> with a list <var title="">memory</var>, the user
agent must run the following steps. These steps either fail or
return a list with a count of errors. The count of errors is used as
part of the authoring conformance criteria below.</p>

<ol><li><p>If <var title="">root</var> is in <var title="">memory</var>, then the algorithm fails; abort these
steps.</li>

<li><p><a href=#collect-all-the-elements-in-the-item>Collect all the elements in the item</a> <var title="">root</var>; let <var title="">results</var> be the
resulting list of elements, and <var title="">errors</var> be the
resulting count of errors.</li>

<li><p>Remove any elements from <var title="">results</var> that do
not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute
specified.</li>

<li><p>Let <var title="">new memory</var> be a new list consisting
of the old list <var title="">memory</var> with the addition of
<var title="">root</var>.</li>

<li><p>For each element in <var title="">results</var> that has an
<code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified,
<a href=#crawl-the-properties>crawl the properties</a> of the element, with <var title="">new memory</var> as the memory. If this fails, then remove
the element from <var title="">results</var> and increment <var title="">errors</var>. (If it succeeds, the return value is
discarded.)</li>

<li><p>Sort <var title="">results</var> in <a href=#tree-order>tree
order</a>.</li>
element <var title="">root</var>, the user agent must run the
following steps. These steps are also used to flag <a href=#microdata-error title="microdata error">microdata errors</a>.</p>

<li><p>Return <var title="">results</var> and <var title="">errors</var>.</li>
<ol><li><p>Let <var title="">results</var>, <var title="">memory</var>, and <var title="">pending</var> be empty lists of elements.</li>

</ol><p>To <dfn id=collect-all-the-elements-in-the-item>collect all the elements in the item</dfn> <var title="">root</var>, the user agent must run these steps. They
return a list of elements and a count of errors.</p>
<li><p>Add the element <var title="">root</var> to <var title="">memory</var>.</li>

<ol><li><p>Let <var title="">results</var> and <var title="">pending</var> be empty lists of elements.</li>

<li><p>Let <var title="">errors</var> be zero.</li>

<li><p>Add all the children elements of <var title="">root</var> to
<var title="">pending</var>.</li>
<li><p>Add the child elements of <var title="">root</var>, if any,
to <var title="">pending</var>.</li>

<li><p>If <var title="">root</var> has an <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, <a href=#split-a-string-on-spaces title="split a
string on spaces">split the value of that <code title=attr-itemref>itemref</code> attribute on spaces</a>. For
Expand All @@ -57146,25 +57117,36 @@ <h4 id=associating-names-with-items><span class=secno>5.2.5 </span>Associating n
the <a href=#concept-id title=concept-ID>ID</a> <var title="">ID</var>, then
add the first such element to <var title="">pending</var>.</li>

<li><p><i>Loop</i>: Remove an element from <var title="">pending</var> and let <var title="">current</var> be that
element.</li>
<li><p><i>Loop</i>: If <var title="">pending</var> is empty, jump
to the step labeled <i>end of loop</i>.</li>

<li><p>If <var title="">current</var> is already in <var title="">results</var>, increment <var title="">errors</var>.</li>
<li><p>Remove an element from <var title="">pending</var> and let
<var title="">current</var> be that element.</li>

<li><p>If <var title="">current</var> is not already in <var title="">results</var> and <var title="">current</var> does not
<li><p>If <var title="">current</var> is already in <var title="">memory</var>, there is a <a href=#microdata-error>microdata error</a>;
return to the step labeled <i>loop</i>.</li>

<li><p>Add <var title="">current</var> to <var title="">memory</var>.</li>

<li><p>If <var title="">current</var> does not
have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute,
then: add all the child elements of <var title="">current</var> to
<var title="">pending</var>.</li>

<li><p>If <var title="">current</var> is not already in <var title="">results</var>, then: add <var title="">current</var> to
<var title="">results</var>.</li>
<li><p>If <var title="">current</var> has an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute specified, add it
to <var title="">results</var>.</li>

<li><p><i>End of loop</i>: If <var title="">pending</var> is not
empty, return to the step labeled <i>loop</i>.</li>
<li><p>Return to the step labeled <i>loop</i>.</li>

<li><p>Return <var title="">results</var> and <var title="">errors</var>.</li>
<li><p><i>End of loop</i>: Sort <var title="">results</var> in
<a href=#tree-order>tree order</a>.</li>

</ol><p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if
<li><p>Return <var title="">results</var>.</li>

</ol><p>A document must not contain any <a href=#concept-item title=concept-item>items</a> for which the algorithm to find
<a href=#the-properties-of-an-item>the properties of an item</a> finds any <dfn id=microdata-error title="microdata error">microdata errors</dfn>.</p>

<p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if
its element does not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute.</p>

<p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=used-microdata-items title="used
Expand All @@ -57177,20 +57159,17 @@ <h4 id=associating-names-with-items><span class=secno>5.2.5 </span>Associating n
<p>All <a href=#concept-item title=concept-item>items</a> in a document must be
<a href=#used-microdata-items>used microdata items</a>.</p>

<p>All <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attributes in a
<code><a href=#document>Document</a></code> must be such that there are no cycles in the
graph formed from representing each <a href=#concept-item title=concept-item>item</a> in the <code><a href=#document>Document</a></code> as a
node in the graph and each <a href=#the-properties-of-an-item title="the properties of an
item">property</a> of an item whose <a href=#concept-property-value title=concept-property-value>value</a> is another item as an
edge in the graph connecting those two items.</p>

<p>A document must not contain any elements that have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute that would not be
found to be a property of any of the <a href=#concept-item title=concept-item>items</a> in that document were their <a href=#the-properties-of-an-item title="the properties of an item">properties</a> all to be
determined.</p>

<p>A document must not contain any <a href=#concept-item title=concept-item>items</a> for which <a href=#crawl-the-properties title="crawl the
properties">crawling the properties</a> of the element, with an
empty list as the value of <var title="">memory</var>, either fails
or returns an error count other than zero.</p>

<p class=note>The algorithms in this section are especially
inefficient, in the interests of keeping them easy to
understand. Implementors are strongly encouraged to refactor and
optimize them in their user agents.</p>

<div class=example>

<p>In this example, a single license statement is applied to two
Expand Down Expand Up @@ -58685,10 +58664,18 @@ <h4 id=vcard><span class=secno>5.4.1 </span>vCard</h4>

<dd>

<ol><li><p>Let <var title="">value</var> be the result of
<a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> obtained from
<a href=#extracting-a-vcard>extracting a vCard</a> from the element that
represents <var title="">subitem</var>.</li>
<ol><li>

<p>If the user agent is already attempting to <a href=#extracting-a-vcard title="extracting a vCard">extract a vCard</a> from the
element that represents <var title="">subitem</var>, then
let <var title="">value</var> be the string "<code title="">ERROR</code>".</p>

<p>Otherwise, let <var title="">value</var> be the result of
<a href=#escaping-the-vcard-text-string>escaping the vCard text string</a> obtained from
<a href=#extracting-a-vcard>extracting a vCard</a> from the element that
represents <var title="">subitem</var>.</p>

</li>

<li><p>Add a parameter named "<code title="">VALUE</code>"
whose value is "<code title="">VCARD</code>" to <var title="">parameters</var>.</li>
Expand Down Expand Up @@ -59976,10 +59963,12 @@ <h4 id=json><span class=secno>5.5.1 </span>JSON</h4>
to JSON.</li>

</ol><p>When the user agent is to <dfn id=get-the-object>get the object</dfn> for an item
<var title="">item</var>, it must run the following substeps:</p>
<var title="">item</var>, optionally with a list of elements <var title="">memory</var>, it must run the following substeps:</p>

<ol><li><p>Let <var title="">result</var> be an empty object.</li>

<li><p>Add <var title="">item</var> to <var title="">memory</var>.</li>

<li><p>If the <var title="">item</var> has an <a href=#item-type>item
type</a>, add an entry to <var title="">result</var> called
"<code title="">type</code>" whose value is the <a href=#item-type>item
Expand All @@ -60003,10 +59992,10 @@ <h4 id=json><span class=secno>5.5.1 </span>JSON</h4>

<ol><li><p>Let <var title="">value</var> be the <a href=#concept-property-value title=concept-property-value>property value</a> of <var title="">element</var>.</li>

<li><p>If <var title="">value</var> is an <a href=#concept-item title=concept-item>item</a>, then <a href=#get-the-object>get the
object</a> for <var title="">value</var>, and then replace
<var title="">value</var> with the object returned from those
steps.</li>
<li><p>If <var title="">value</var> is an <a href=#concept-item title=concept-item>item</a>, then: If <var title="">value</var> is in <var title="">memory</var>, then let
<var title="">value</var> be the string "<code title="">ERROR</code>". Otherwise, <a href=#get-the-object>get the object</a>
for <var title="">value</var>, passing a copy of <var title="">memory</var>, and then replace <var title="">value</var>
with the object returned from those steps.</li>

<li>

Expand Down Expand Up @@ -60169,15 +60158,18 @@ <h4 id=json><span class=secno>5.5.1 </span>JSON</h4>
<var title="">fallback name</var>, it must run the following
steps:</p>

<ol><li><p>If there is an entry for <var title="">item</var> in <var title="">memory</var>, then let <var title="">subject</var> be the
subject of that entry. Otherwise, if <var title="">item</var> has a
<a href=#global-identifier>global identifier</a> and that <a href=#global-identifier>global
identifier</a> is an <a href=#absolute-url>absolute URL</a>, let <var title="">subject</var> be that <a href=#global-identifier>global
identifier</a>. Otherwise, let <var title="">subject</var> be a
new blank node.</li>
<ol><li><p>If there is an entry for the item <var title="">item</var>
in <var title="">memory</var>, then return the subject of that
entry and abort these steps.</li>

<li><p>If <var title="">item</var> has a <a href=#global-identifier>global
identifier</a> and that <a href=#global-identifier>global identifier</a> is an
<a href=#absolute-url>absolute URL</a>, let <var title="">subject</var> be that
<a href=#global-identifier>global identifier</a>. Otherwise, let <var title="">subject</var> be a new blank node.</li>

<li><p>Add a mapping from <var title="">item</var> to <var title="">subject</var> in <var title="">memory</var>, if there
isn't one already.</li>
<li><p>Add a mapping from the item <var title="">item</var> to the
subject <var title="">subject</var> in <var title="">memory</var>,
if there isn't one already.</li>

<li><p>If <var title="">item</var> has an <a href=#item-type>item type</a>
and that <a href=#item-type>item type</a> is an <a href=#absolute-url>absolute URL</a>,
Expand Down Expand Up @@ -60265,7 +60257,7 @@ <h4 id=json><span class=secno>5.5.1 </span>JSON</h4>

<!-- could support <time> here somehow, though we'd have to
reserialise it, check if the <time> was valid, check if it had a
date, a time, a timezone, etc. -->
date, a time, a timezone, etc. (<code>time</code>) -->

<li><p>Otherwise, if <var title="">element</var> is not one of
the <a href=#url-property-elements>URL property elements</a>, let <var title="">value</var> be a plain literal, with the language
Expand Down

0 comments on commit d827034

Please sign in to comment.