shex.js
shex.js copied to clipboard
recursion loophole
Following shema and data, results in a pass while should give a failure.
This is triggered because the ( :test @<A>* | :test @<E>* ); causes a recursive check on <a> and then <c>. When <c> is checked it gets the success status because <a> is in the recursion cache.
So when :test2 @<C> ; is executed <c> is already in the passed list and so it will pass.
Schema: [[
PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
start = @<D>
<D> {
:predd xsd:string ;
( :test @<A>* | :test @<E>* );
:test2 @<C> ;
}
<E> { :prede xsd:string ; }
<A> { :subject @<C> ; :preda xsd:string }
<C> { :subject @<A> ; :predc xsd:string }
]]
Data: [[
PREFIX : <http://hl7.org/fhir/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
<d> :predd "final" ; :test <a> ; :test2 <c> .
<a> :subject <c> ; :prede "final" .
<c> :subject <a> ; :predc "final" .
]]
Here's a web interface emulation of this problem. You may have a clever strategy but from what I can envision right now, this requires multi-modal logic. Essentially, I need to try both combinations of pass and fail for every reentrant node/shape pair.