Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-04-2022 08:01 AM
Occasionally I need to use HTML character codes as a part of the query string, like ’
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
01-06-2022 04:15 AM
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
01-06-2022 10:17 AM
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.
All the sessions of the conference are now available online