[Kimchi-devel] [PATCH 1/2] Issue #243: start/stop/display a VM whose name with "?"
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Feb 24 13:25:11 UTC 2014
Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>
On 02/23/2014 11:58 PM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> create a VM with name ubuntu?guest4
> start/stop/display this VM
>
> Kimchi will throw a exception:
> "Unexpected query string parameters: guest4"
>
> That's because the URL is not quoted when internal_redirect.
>
> Also unquote the ident before dispatch the resource.
>
> issue:
> https://github.com/kimchi-project/kimchi/issues/243
>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
> ---
> src/kimchi/control/base.py | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
> index 048dd34..50f8c43 100644
> --- a/src/kimchi/control/base.py
> +++ b/src/kimchi/control/base.py
> @@ -54,7 +54,6 @@ class Resource(object):
> """
> def __init__(self, model, ident=None):
> self.model = model
> - ident = ident if ident is None else urllib2.unquote(ident)
> self.ident = ident
> self.model_args = (ident,)
> self.update_params = []
> @@ -76,7 +75,8 @@ class Resource(object):
> fn = getattr(self.model, model_fn(self, action_name))
> ident = fn(*model_args)
> self._redirect(ident)
> - uri_params = tuple(self.model_args)
> + uri_params = tuple([urllib2.quote(arg.encode('utf-8'), safe="")
> + for arg in self.model_args])
> raise internal_redirect(self.uri_fmt % uri_params)
> except MissingParameter, e:
> raise cherrypy.HTTPError(400, e.message)
> @@ -238,6 +238,7 @@ class Collection(object):
> def _cp_dispatch(self, vpath):
> if vpath:
> ident = vpath.pop(0)
> + ident = urllib2.unquote(ident)
> # incoming text, from URL, is not unicode, need decode
> args = self.resource_args + [ident.decode("utf-8")]
> return self.resource(self.model, *args)
More information about the Kimchi-devel
mailing list