correctly escape msgs when we search in database

This commit is contained in:
Yann Leboulanger 2009-12-03 18:59:10 +01:00
parent b739802fd7
commit 3f4f07d326
1 changed files with 3 additions and 4 deletions

View File

@ -1005,15 +1005,14 @@ class Logger:
elif direction == 'to':
type_ = 'chat_msg_sent'
jid_id = self.get_jid_id(with_)
where_sql = 'jid_id = %s AND message="%s"' % (jid_id, msg)
where_sql = 'jid_id = %s AND message=?' % (jid_id)
if type_ == 'gc_msg':
# We cannot differentiate gc message and pm messages, so look in both
# logs
with_2 = gajim.get_jid_without_resource(with_)
if with_ != with_2:
jid_id2 = self.get_jid_id(with_2)
where_sql = 'jid_id in (%s, %s) AND message="%s"' % (jid_id,
jid_id2, msg)
where_sql = 'jid_id in (%s, %s) AND message=?' % (jid_id, jid_id2)
start_time = time_col - 300 # 5 minutes arrount given time
end_time = time_col + 300 # 5 minutes arrount given time
self.cur.execute('''
@ -1021,7 +1020,7 @@ class Logger:
WHERE (%s)
AND time BETWEEN %d AND %d
ORDER BY time
''' % (where_sql, start_time, end_time))
''' % (where_sql, start_time, end_time), (msg,))
results = self.cur.fetchall()
if results:
log.debug('Log already in DB, ignoring it')