mala::home Davide “+mala” Eynard’s website

11Nov/090

All for a question mark

Hey, did you know that the "where" keyword in the "where" clause in SPARQL is optional? Yep, you can check it here!

What does this mean? Well, instead of writing something like

select ?s ?p ?o where{
  ?s ?p ?o
}

you can write

select ?s ?p ?o {
  ?s ?p ?o
}

So, what's the problem? Well, there is no problem... But what if you forget a space and write the following?

select ?s ?p ?owhere {
  ?s ?p ?o
}

I guess you can understand what this means :) Of course it is very easy to spot this error, but what if you are building the query string like the following one?

$query  = "select ?s ?p ?o";
$query .= "where {\n";
$query .= "  ?s ?p ?o\n";
$query .= "}";

I know, I know, that is a quick and dirty way of doing it, and anyone who does this should pay the fee. But what if a poor student forgets a \n in the concatenation, the system does not return any error, and all the objects you were asking for are not returned? Be aware, friends, and don't repeat his mistake... ;-)

[thanks Sarp for providing me the chance to spot this error - it was a funny reversing exercise!]

Filed under: research No Comments