[Kimchi-devel] [PATCH 3/3] Bug fix: Access guest console when guest name has non-ASCII characters

Ramon Medeiros ramonn at linux.vnet.ibm.com
Thu Sep 3 20:11:28 UTC 2015


Reviewed-By: Ramon Medeiros <ramonn at br.ibm.com>
Tested-By: Ramon Medeiros <ramonn at br.ibm.com>

On 09/03/2015 09:52 AM, Aline Manera wrote:
> atob() and btoa() do not work well with non-ASCII characters which turns into
> a wrong base64 result.
> For example, "café" would be "Y2Fmw6k" but btod() turns it into "Y2Fm6Q"
> This was preventing Kimchi to launch the guest console when guest name had
> non-ASCII characaters.
>
> Jquery Base64 has UTF-8 support so it can properly encode/decode strings with
> non-ASCII characters.
>
> Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.utils.js    | 6 +++---
>   ui/pages/kimchi-ui.html.tmpl | 1 +
>   2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/ui/js/src/kimchi.utils.js b/ui/js/src/kimchi.utils.js
> index f26a560..2fc7dfa 100644
> --- a/ui/js/src/kimchi.utils.js
> +++ b/ui/js/src/kimchi.utils.js
> @@ -1,7 +1,7 @@
>   /*
>    * Project Kimchi
>    *
> - * Copyright IBM, Corp. 2013-2014
> + * Copyright IBM, Corp. 2013-2015
>    *
>    * Licensed under the Apache License, Version 2.0 (the "License");
>    * you may not use this file except in compliance with the License.
> @@ -185,9 +185,9 @@ kimchi.escapeStr = function(str) {
>   };
>   
>   kimchi.urlSafeB64Decode = function(str) {
> -    return atob(str.replace(/-/g, '+').replace(/_/g, '/'));
> +    return $.base64.atob(str.replace(/-/g, '+').replace(/_/g, '/'), true);
>   }
>   
>   kimchi.urlSafeB64Encode = function(str) {
> -    return btoa(str).replace(/\+/g, '-').replace(/\//g, '_');
> +    return $.base64.btoa(str, true).replace(/\+/g, '-').replace(/\//g, '_');
>   }
> diff --git a/ui/pages/kimchi-ui.html.tmpl b/ui/pages/kimchi-ui.html.tmpl
> index 8da8acc..548f5c8 100644
> --- a/ui/pages/kimchi-ui.html.tmpl
> +++ b/ui/pages/kimchi-ui.html.tmpl
> @@ -36,6 +36,7 @@
>   <script src="$href('libs/jquery-1.10.0.min.js')"></script>
>   <script src="$href('libs/jquery-ui.min.js')"></script>
>   <script src="$href('libs/jquery-ui-i18n.min.js')"></script>
> +<script src="$href('base64/jquery.base64.js')"></script>
>   <script src="$href('js/kimchi.min.js')"></script>
>   
>   <!-- This is used for detecting if the UI needs to be built -->

-- 

Ramon Nunes Medeiros
Kimchi Developer
Linux Technology Center Brazil
IBM Systems & Technology Group
Phone : +55 19 2132 7878
ramonn at br.ibm.com




More information about the Kimchi-devel mailing list