gkellogg / rdf-distiller

Translate any RDF format to any other using Ruby RDF gems
http://rdf.greggkellogg.net/
The Unlicense
21 stars 6 forks source link

Internal server error on invalid input (circular itemrefs) #6

Closed Janpot closed 9 years ago

Janpot commented 9 years ago
<div itemscope>
  <div id="ref">
    <div itemprop="name">friend1</div>
    <div itemprop="friend" itemscope>
      <div itemprop="name">friend2</div>
      <div itemprop="friend" itemscope itemref="ref"></div>
    </div>
  </div>
</div>

This is invalid but crashes the server

gkellogg commented 9 years ago

I updated it to version 1.1.9, which includes a fix to the Microdata processor to look for such recursion. Thanks! Turn on validation to see the error.

(Also added as a negative syntax test to the Microdata to RDF test suite).

Janpot commented 9 years ago

I might be wrong but it seems like the 'microdata to rdf' algorithm doesn't check for circular structures while the 'microdata to json' algorithm does. The microdata spec prohibits circular structures though.

I solved it for me by adding an 'ancestors' array to the context in here.

Thanks for updating the suite, I run my parser to it too.

gkellogg commented 9 years ago

Microdata to RDF mostly defers to the Microdata spec for processing, and it does have such checks. However, these are now in the JSON processing steps, so some amount of developer license is necessary. A formal spec would likely need to add clarity. A test will help ensure that known pathological cases are detected.

gkellogg commented 9 years ago

We should have a wiki on the w3c Microdata-RDF repo to catalog implementations, and perhaps, collect implementation reports.