--- a/src/pyams_viewlet/provider.py Mon Jun 11 15:58:05 2018 +0200
+++ b/src/pyams_viewlet/provider.py Wed Oct 03 15:11:04 2018 +0200
@@ -12,23 +12,27 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
+import re
-# import interfaces
-from zope.contentprovider.interfaces import IContentProvider, ContentProviderLookupError, BeforeUpdateEvent
+from chameleon.astutil import Symbol
+from chameleon.tales import StringExpr
+from pyramid_zope_request import PyramidPublisherRequest
+from zope.contentprovider.interfaces import BeforeUpdateEvent, ContentProviderLookupError, IContentProvider
+from zope.contentprovider.tales import addTALNamespaceData
from zope.location.interfaces import ILocation
-# import packages
-from chameleon.astutil import Symbol
-from chameleon.tales import StringExpr
from pyams_utils.tales import ContextExprMixin
-from pyramid_zope_request import PyramidPublisherRequest
-from zope.contentprovider.tales import addTALNamespaceData
+
+
+CONTENT_PROVIDER_NAME = re.compile('([A-Za-z0-9_\-\.]+)')
def render_content_provider(econtext, name):
- name = name.strip()
+ match = CONTENT_PROVIDER_NAME.match(name.strip())
+ if match:
+ name = match.groups()[0]
+ else:
+ raise ContentProviderLookupError(name)
context = econtext.get('context')
request = econtext.get('request')