From 51f60b4a40e0521036693ba2bb6de0075c01982c Mon Sep 17 00:00:00 2001 From: switch87 Date: Mon, 12 Oct 2015 20:16:15 +0200 Subject: [PATCH] throw exception when key longer than 64 characters Merges upstream disqus/gargoyle#103. --- gargoyle/manager.py | 5 +++++ gargoyle/testutils.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/gargoyle/manager.py b/gargoyle/manager.py index 2c38e755..605adbe5 100644 --- a/gargoyle/manager.py +++ b/gargoyle/manager.py @@ -41,6 +41,11 @@ def is_active(self, key, *instances, **kwargs): >>> gargoyle.is_active('my_feature', request) """ + + # check for varchar(64) + if len(key) > 64: + raise ValueError('Gargoyle key can be max 64 chars, was: %s' % len(key)) + default = kwargs.pop('default', False) # Check all parents for a disabled state diff --git a/gargoyle/testutils.py b/gargoyle/testutils.py index 21a6a15b..bb3faeac 100644 --- a/gargoyle/testutils.py +++ b/gargoyle/testutils.py @@ -59,6 +59,11 @@ def is_active(gargoyle): is_active_func = gargoyle.is_active def wrapped(key, *args, **kwargs): + + # check for varchar(64) + if len(key) > 64: + raise ValueError('Gargoyle key can be max 64 chars, was: %s' % len(key)) + if key in self.keys: return self.keys[key] return is_active_func(key, *args, **kwargs)