Quotes in SPARQL queries

6 views
Skip to first unread message

tj.sch...@gmail.com

unread,
Apr 23, 2015, 5:07:38 AM4/23/15
to sta...@clarkparsia.com
Hi,

In my SPARQL queries, I use single quotes as delimiters. In my opinion, an enclosed double quote should work fine:



SELECT ?s

WHERE
{

   
?s <http://jena.hpl.hp.com/ARQ/property#textMatch> ('mysearch"')

}




In Stardog 2.2.4, I get the following syntactical error:

java.lang.RuntimeException: com.complexible.stardog.plan.eval.operator.OperatorException: Cannot parse 'Lebens"': Lexical error at line -6, column 8.  Encountered: <EOF> after : ""


Is this behaviour correct? I guess rather not since I do not have this problem with dbpedia's SPARQL endpoint.

If I included an unescaped single quote in the string, an error should be thrown (since it is used as a delimiter). We have to escape the single quotes in order to prevent injections. Is there a standard string check to prevent injections?




Michael Grove

unread,
Apr 23, 2015, 7:38:08 AM4/23/15
to stardog
Are you running this via the command line?  If so, you have to be careful with your quoting.

But I'm not able to replicate the behavior you describe:

mhgrove:dist mhgrove$ cat query.sparql

SELECT ?s

WHERE {
    ?s <urn:foo> ('mysearch"')
}

mhgrove:dist mhgrove$ ./bin/stardog query foo query.sparql

+-------+

|   s   |

+-------+

+-------+


Query returned 0 results in 00:00:00.039

Cheers,

Mike


--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Tobias Schweizer

unread,
Apr 23, 2015, 8:06:06 AM4/23/15
to sta...@clarkparsia.com
I tried this via the web GUI

It also fails when trying to send it via HTTP
--

happens

Michael Grove

unread,
Apr 23, 2015, 8:10:14 AM4/23/15
to stardog
On Thu, Apr 23, 2015 at 8:06 AM, Tobias Schweizer <tj.sch...@gmail.com> wrote:
I tried this via the web GUI

It also fails when trying to send it via HTTP

I tried over HTTP via the CLI and with the webconsole and it worked fine.

It might be something that we fixed between 2.2.4 and 3.0.1.

Cheers,

Mike
Reply all
Reply to author
Forward
0 new messages