[Cubicweb] escape for RQL insertion

Dimitri Papadopoulos Orfanos dimitri.papadopoulos at cea.fr
Thu Oct 24 12:12:42 CEST 2013


Dear all,

The RQL documentation reads:
	2.2.5. Literal expressions
	Bases types supported by RQL are those supported by yams
	schema. Literal values are expressed as explained below:
	* string should be between double or single quotes. If
	the value contains a quote, it should be preceded by
	a backslash ‘\’

1. How to escape the backslash itself?

2. Is there an existing function to escape and sanitize text before 
programmatically inserting it using RQL? Such an escape function would 
look like:
	def escape(s):
	    s = s.replace('\\', '\\\\')
	    s = s.replace('"', '\\"')
	    s = s.replace("'", "\\'")
	    return s

-- 
Dimitri Papadopoulos
CEA/Saclay
I2BM, NeuroSpin
F-91191 Gif-sur-Yvette cedex, France



More information about the Cubicweb mailing list