cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Can Cypher interpret HTML character codes as input?

Occasionally I need to use HTML character codes as a part of the query string, like &#8217 for ', and ] for ]. I know that there is a way to convert them back to the proper characters to be able to use Cypher, but is there a way to make Cypher automatically decode them?That would be neater.

So for example if my query is

match (n)-[r]-(m) where n.gid=’Cx’ and m.gid=’Cx’ return n,r,m

it will understand as

match (n)-[r]-(m) where n.gid='Cx' and m.gid='Cx' return n,r,m
2 REPLIES 2

There are a couple of different ways of doing this, but I would check out apoc.text.urldecode here

However -- the code that you've got here suggests that the cypher query itself is being submitted as a URL encoded string, and that you are interpolating that URL encoded data as part of an actual cypher query. If this is the case, please reconsider your approach because it would likely make your application vulnerable to a security problem called cypher query injection. You can read more about that here

Thanks for the info. However, this is a HTML entity, not percent-encoding that is used for URL. My input is in a div, i.e.

<div id="foo" data-function="bar">match (n)-[r]-() where n.gid='Cx' return n,r</div>

and the ' character is being converted before putting it into a string.