mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-22 20:12:04 -06:00
[IMP]Add functions for manage input filename and cmis query
This commit is contained in:
parent
f1b92c915d
commit
0801271125
@ -137,6 +137,18 @@ class cmis_backend(orm.Model):
|
||||
raise orm.except_orm(_('Cmis Error!'),
|
||||
_("Error path for : " + path))
|
||||
|
||||
# Escape the name for characters not supported in filenames
|
||||
def sanitize_input(self, file_name):
|
||||
# for avoiding SQL Injection
|
||||
file_name = file_name.replace("'", "\\'")
|
||||
file_name = file_name.replace("%", "\%")
|
||||
file_name = file_name.replace("_", "\_")
|
||||
return file_name
|
||||
|
||||
def safe_query(self, query, file_name, repo):
|
||||
args = map(self.sanitize_input, file_name)
|
||||
return repo.query(query % ''.join(args))
|
||||
|
||||
_columns = {
|
||||
'version': fields.selection(
|
||||
_select_versions,
|
||||
|
Loading…
Reference in New Issue
Block a user