From 9da0da9ff3bc25876322a074f67817dc64a32602 Mon Sep 17 00:00:00 2001
From: Dariusz Kedzierski <dkedzierski@syncad.com>
Date: Wed, 24 Jun 2020 15:24:52 +0200
Subject: [PATCH] Improved escaping

---
 hive/indexer/post_data_cache.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hive/indexer/post_data_cache.py b/hive/indexer/post_data_cache.py
index 35c6ba169..83514c05a 100644
--- a/hive/indexer/post_data_cache.py
+++ b/hive/indexer/post_data_cache.py
@@ -5,10 +5,12 @@ log = logging.getLogger(__name__)
 DB = Db.instance()
 
 def escape_characters(text):
-    characters = ["'", "_", "%"]
     ret = str(text)
-    for ch in characters:
-        ret = ret.replace(ch, "\\" + ch)
+    ret = ret.replace("\\", "\\\\")
+    ret = ret.replace("'", "''")
+    ret = ret.replace("%", '%%')
+    ret = ret.replace("_", "\\_")
+    ret = ret.replace(":", "\\:")
     return ret
 
 class PostDataCache(object):
-- 
GitLab