Skip to content

Commit

Permalink
Fix use of double-quoted strings in SQLite queries (borisbabic#96)
Browse files Browse the repository at this point in the history
Double-quotes are used for identifiers, not strings. While SQLite will interpret unknown identifiers that use double-quotes as strings, this is considered a misfeature. This commit fixes the SQL for those of us with double-quoted strings disabled, as well as fixes setting domain_name to the name of a column in the SQLite table.

Co-authored-by: Mcsticken <[email protected]>
  • Loading branch information
Derothin and Mcsticken authored Oct 8, 2021
1 parent 87b7068 commit bd099aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ def load(self):
try:
# chrome <=55
cur.execute('SELECT host_key, path, secure, expires_utc, name, value, encrypted_value '
'FROM cookies WHERE host_key like "%{}%";'.format(self.domain_name))
'FROM cookies WHERE host_key like ?;', ('%{}%'.format(self.domain_name),))
except sqlite3.OperationalError:
# chrome >=56
cur.execute('SELECT host_key, path, is_secure, expires_utc, name, value, encrypted_value '
'FROM cookies WHERE host_key like "%{}%";'.format(self.domain_name))
'FROM cookies WHERE host_key like ?;', ('%{}%'.format(self.domain_name),))

cj = http.cookiejar.CookieJar()

Expand Down Expand Up @@ -606,7 +606,7 @@ def load(self):
con = sqlite3.connect(self.tmp_cookie_file)
cur = con.cursor()
cur.execute('select host, path, isSecure, expiry, name, value from moz_cookies '
'where host like "%{}%"'.format(self.domain_name))
'where host like ?', ('%{}%'.format(self.domain_name),))

cj = http.cookiejar.CookieJar()
for item in cur.fetchall():
Expand Down

0 comments on commit bd099aa

Please sign in to comment.