diff options
-rw-r--r-- | libmproxy/contentviews.py | 10 | ||||
-rw-r--r-- | test/test_contentview.py | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libmproxy/contentviews.py b/libmproxy/contentviews.py index 8d5aadfc..aa2082d1 100644 --- a/libmproxy/contentviews.py +++ b/libmproxy/contentviews.py @@ -520,8 +520,18 @@ def add(obj): if i.name == obj.name: raise ContentViewException("Duplicate view: " + obj.name) + for prompt in view_prompts: + if prompt[1] == obj.prompt[1]: + raise ContentViewException("Duplicate view shortcut: " + obj.prompt[1]) + views.append(obj) + for ct in obj.content_types: + l = content_types_map.setdefault(ct, []) + l.append(obj) + + view_prompts.append(obj.prompt) + def get(name): for i in views: diff --git a/test/test_contentview.py b/test/test_contentview.py index 68272fca..c1e437e4 100644 --- a/test/test_contentview.py +++ b/test/test_contentview.py @@ -217,6 +217,7 @@ Larry tcv = TestContentView() cv.add(tcv) + # repeated addition causes exception tutils.raises( ContentViewException, cv.add, |