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

apoc built in urlencode does not handle newlines correctly #65

Closed
neo-technology-build-agent opened this issue Sep 1, 2022 · 2 comments

Comments

@neo-technology-build-agent
Copy link
Collaborator

Issue by kuczera
Friday Nov 26, 2021 at 17:38 GMT
Originally opened as neo4j-contrib/neo4j-apoc-procedures#2377


Guidelines

Please note that GitHub issues are only meant for bug reports/feature requests. If you have questions on how to use APOC, please ask on the Neo4j Discussion Forum instead of creating an issue here.

Expected Behavior (Mandatory)

With this query i get ans answer from wikidata:

WITH 'SELECT * WHERE { ?person wdt:P106 wd:Q10833314 ; rdfs:label "Nick Kyrgios"@en ; wdt:P569 ?dateOfBirth ; wdt:P27 [ rdfs:label ?countryName ] . filter(lang(?countryName) = "en")}' AS sparql
CALL apoc.load.jsonParams("https://query.wikidata.org/sparql?query=" + sparql,
  { Accept: "application/sparql-results+json"},
  null
)
YIELD value
RETURN value

Actual Behavior (Mandatory)

If you put a newline in the SPARQL-part the query fails

WITH 'SELECT * WHERE { 
    ?person wdt:P106 wd:Q10833314 ; rdfs:label "Nick Kyrgios"@en ; wdt:P569 ?dateOfBirth ; wdt:P27 [ rdfs:label ?countryName ] . filter(lang(?countryName) = "en")}' AS sparql
CALL apoc.load.jsonParams("https://query.wikidata.org/sparql?query=" + sparql,
  { Accept: "application/sparql-results+json"},
  null
)
YIELD value
RETURN value

How to Reproduce the Problem

see above

Simple Dataset (where it's possibile)

//Insert here a set of Cypher statements that helps us to reproduce the problem

Steps (Mandatory)

Screenshots (where it's possibile)

Bildschirmfoto 2021-11-26 um 18 37 16

Specifications (Mandatory)

Neo4j 4.3.6

Versions

  • OS: all
  • Neo4j: 4.3.6
  • Neo4j-Apoc: apoc-4.3.0.3.jar
@neo-technology-build-agent
Copy link
Collaborator Author

Comment by vga91
Thursday Dec 16, 2021 at 13:41 GMT


@kuczera

As a fast workaround, currently you could substitute "https://query.wikidata.org/sparql?query=" + sparql with this: replace("https://query.wikidata.org/sparql?query=" + sparql, "\n", "")

@hvub
Copy link
Collaborator

hvub commented Nov 21, 2024

This is not bug. The argument of the query parameter needs to be url encoded for the URI to be a valid URI by the rules of the URI standard. URL encoding can be done with apoc.text.urlencode. This query runs fine:

WITH apoc.text.urlencode('SELECT * WHERE { 
    ?person wdt:P106 wd:Q10833314 ; rdfs:label "Nick Kyrgios"@en ; wdt:P569 ?dateOfBirth ; wdt:P27 [ rdfs:label ?countryName ] . filter(lang(?countryName) = "en")}') AS sparql
CALL apoc.load.jsonParams("https://query.wikidata.org/sparql?query=" + sparql,
  { Accept: "application/sparql-results+json"},
  null
)
YIELD value
RETURN value

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