From 8935c3bde9e9635f65522488c1aca5df5b03050d Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 7 Nov 2012 23:28:28 -0800 Subject: Limit formatting routes when adding resources By default, routes.mapper.Mapper.resource adds a bunch of formatted routes that accept anything after a '.'. Our spec says only .xml and .json are accepted so limit the formatting to those valuse. This allows identifiers with a '.' in urls. A few tests were added to the extensions test to prove that .xml and .json are stripped but other values are not. Change-Id: Ic888aa5d75050d6b14763c2a787ac8c8d5ab1f69 --- nova/api/openstack/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index d27b018c2..67ea6e1b5 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -90,6 +90,15 @@ class APIMapper(routes.Mapper): return result[0], result[1] return routes.Mapper.routematch(self, url, environ) + def connect(self, *args, **kargs): + # NOTE(vish): Default the format part of a route to only accept json + # and xml so it doesn't eat all characters after a '.' + # in the url. + kargs.setdefault('requirements', {}) + if not kargs['requirements'].get('format'): + kargs['requirements']['format'] = 'json|xml' + return routes.Mapper.connect(self, *args, **kargs) + class ProjectMapper(APIMapper): def resource(self, member_name, collection_name, **kwargs): -- cgit