Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct POST of SPARQL queries not working correctly when ampersand (&) is involved. #1493

Open
Aklakan opened this issue Sep 11, 2024 · 1 comment

Comments

@Aklakan
Copy link

Aklakan commented Sep 11, 2024

Hi,

There is an issue when sending an unencoded SPARQL query with Content-Type: application/sparql-query. Some characters cause issues then (see below).

Because Apache Jena uses this approach for longer query strings it would be very useful if that worked frictionlessly for interoperability.

According to the SPARQL specification

2.1.3 query via POST directly

Protocol clients may send protocol requests via the HTTP POST method by including the query directly and unencoded as the HTTP request message body. When using this approach, clients must include the SPARQL query string, unencoded, and nothing else as the message body of the request. Clients must set the content type header of the HTTP request to application/sparql-query. Clients may include the optional default-graph-uri and named-graph-uri parameters as HTTP query string parameters in the request URI. Note that UTF-8 is the only valid charset here.

POST with form encoding (works)

curl http://localhost:7001 --data-urlencode 'query=SELECT ?s { ?s a ?o FILTER(true && true)} LIMIT 10'
{"head":{"vars":["s"]},"results":{"bindings":[{"s":{"type":"uri","value":"https://www.wikidata.org/wiki/Special:EntityData/P10"}}   }}

Direct POST without '&&' (works)

curl http://localhost:7001 -H 'Content-Type: application/sparql-query' --data 'SELECT ?s { ?s a ?o } LIMIT 10'
{"head":{"vars":["s"]},"results":{"bindings":[{"s":{"type":"uri","value":"https://www.wikidata.org/wiki/Special:EntityData/P10"}}   }}

Direct POST with '&&' (fails)

curl http://localhost:7001 -H 'Content-Type: application/sparql-query' --data 'SELECT ?s { ?s a ?o FILTER(true && true)} LIMIT 10'
Parameter without "=" in HTTP Request. . In file "/app/src/util/http/UrlParser.cpp " at line 100

Not sure whether there are further characters that cause problems; in any case there is some issue with encoding/decoding of chars.

@Qup42
Copy link
Member

Qup42 commented Sep 29, 2024

@Aklakan we recently merged #1417 which replaced the old URL parsing code and this should work now. Can you please try again with the newest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants