Skip to content

Commit cfe583a

Browse files
authored
Merge pull request #522 from JuliaRobotics/bug/521_CGDFG_regex_escaping
Fixing CGDFG escaping issue #521
2 parents e2ddf93 + 8ba6045 commit cfe583a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/CloudGraphsDFG/services/CloudGraphsDFG.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ function listVariables(dfg::CloudGraphsDFG, regexFilter::Union{Nothing, Regex}=n
347347
if regexFilter == nothing
348348
return _getLabelsFromCyphonQuery(dfg.neo4jInstance, "(node:$(join(_getLabelsForType(dfg, DFGVariable),':'))) where node.solvable >= $solvable $tagsFilter")
349349
else
350-
return _getLabelsFromCyphonQuery(dfg.neo4jInstance, "(node:$(join(_getLabelsForType(dfg, DFGVariable),':'))) where node.label =~ '$(regexFilter.pattern)' and node.solvable >= $solvable $tagsFilter")
350+
# Neoj4j needs regexes to have double slashes, such as \\d, instead of \d.
351+
# This may cause issues with complex expressions, hoping Neo4j is consistent with this!
352+
doubleSlashesExpr = replace(regexFilter.pattern, "\\" => "\\\\")
353+
return _getLabelsFromCyphonQuery(dfg.neo4jInstance, "(node:$(join(_getLabelsForType(dfg, DFGVariable),':'))) where node.label =~ '$doubleSlashesExpr' and node.solvable >= $solvable $tagsFilter")
351354
end
352355
end
353356

0 commit comments

Comments
 (0)