Compare commits

...

6 Commits

Author SHA1 Message Date
Tim
42ff4a2f62 Merge branch 'dev' 2015-12-06 20:02:18 +02:00
Tim
3fa5f80fc4 v1.2.12 2015-12-06 20:01:38 +02:00
drzoidberg33
9b5b7ef8db Merge pull request #343 from drzoidberg33/security-fixes
No need to sanitize same items more than once.
2015-12-06 19:59:34 +02:00
Tim
560acf62fe No need to sanitize same items more than once. 2015-12-06 18:45:02 +02:00
drzoidberg33
27d12922da Merge pull request #339 from drzoidberg33/security-fixes
Move dict_factory out of database class.
2015-12-06 18:10:26 +02:00
Tim
37b92f3d88 Move dict_factory out of database class. 2015-12-06 18:09:18 +02:00
6 changed files with 18 additions and 27 deletions

View File

@@ -1,5 +1,10 @@
# Changelog
## v1.2.12 (2015-12-06)
* Fix for "too many open files" error.
## v1.2.11 (2015-12-06)
* Fix more regressions (sorry).

View File

@@ -46,6 +46,13 @@ def get_cache_size():
return 0
return int(plexpy.CONFIG.CACHE_SIZEMB)
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
class MonitorDatabase(object):
@@ -58,14 +65,7 @@ class MonitorDatabase(object):
self.connection.execute("PRAGMA journal_mode = %s" % plexpy.CONFIG.JOURNAL_MODE)
# 64mb of cache memory, probably need to make it user configurable
self.connection.execute("PRAGMA cache_size=-%s" % (get_cache_size() * 1024))
self.connection.row_factory = self.dict_factory
def dict_factory(self, cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
self.connection.row_factory = dict_factory
def action(self, query, args=None, return_last_id=False):
if query is None:

View File

@@ -108,9 +108,6 @@ class DataFactory(object):
# Rename Mystery platform names
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
# Sanitize player name
player = helpers.sanitize(item["player"])
row = {"reference_id": item["reference_id"],
"id": item["id"],
"date": item["date"],
@@ -122,7 +119,7 @@ class DataFactory(object):
"user": item["user"],
"friendly_name": item["friendly_name"],
"platform": platform,
"player": player,
"player": item['player'],
"ip_address": item["ip_address"],
"media_type": item["media_type"],
"rating_key": item["rating_key"],
@@ -575,9 +572,6 @@ class DataFactory(object):
else:
thumb = item['grandparent_thumb']
# Sanitize player name
player = helpers.sanitize(item["player"])
row = {'row_id': item['id'],
'user': item['user'],
'friendly_name': item['friendly_name'],
@@ -588,7 +582,7 @@ class DataFactory(object):
'thumb': thumb,
'grandparent_thumb': item['grandparent_thumb'],
'last_watch': item['last_watch'],
'player': player,
'player': item['player']
}
last_watched.append(row)

View File

@@ -89,16 +89,13 @@ class Users(object):
# Rename Mystery platform names
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
# Sanitize player name
player = helpers.sanitize(item["player"])
row = {"id": item['id'],
"plays": item['plays'],
"last_seen": item['last_seen'],
"friendly_name": item['friendly_name'],
"ip_address": item['ip_address'],
"platform": platform,
"player": player,
"player": item["player"],
"last_watched": item['last_watched'],
"thumb": thumb,
"media_type": item['media_type'],
@@ -183,15 +180,12 @@ class Users(object):
# Rename Mystery platform names
platform = common.PLATFORM_NAME_OVERRIDES.get(item["platform"], item["platform"])
# Sanitize player name
player = helpers.sanitize(item["player"])
row = {"id": item['id'],
"last_seen": item['last_seen'],
"ip_address": item['ip_address'],
"play_count": item['play_count'],
"platform": platform,
"player": player,
"player": item['player'],
"last_watched": item['last_watched'],
"thumb": thumb,
"media_type": item['media_type'],

View File

@@ -1,2 +1,2 @@
PLEXPY_VERSION = "master"
PLEXPY_RELEASE_VERSION = "1.2.11"
PLEXPY_RELEASE_VERSION = "1.2.12"

View File

@@ -735,8 +735,6 @@ class WebInterface(object):
if not session['ip_address']:
ip_address = data_factory.get_session_ip(session['session_key'])
session['ip_address'] = ip_address
# Sanitize player name
session['player'] = helpers.sanitize(session['player'])
except:
return serve_template(templatename="current_activity.html", data=None)