<html>
  <head>
    <meta content="text/html; charset=GB2312" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 07/29/2014 10:22 AM, Zheng Sheng ZS
      Zhou wrote:<br>
    </div>
    <blockquote
cite="mid:OFA484BD05.A789300B-ON48257D24.000CD77B-48257D24.000D180D@cn.ibm.com"
      type="cite">
      <p><tt><font size="2">Sheldon <a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
            wrote 2014-07-28 17:23:21:<br>
            <br>
            &gt; From: Sheldon <a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a></font></tt><br>
        <tt><font size="2">&gt; To: <a class="moz-txt-link-abbreviated" href="mailto:alinefm@linux.vnet.ibm.com">alinefm@linux.vnet.ibm.com</a>, Kimchi
            Devel &lt;kimchi-<br>
            &gt; <a class="moz-txt-link-abbreviated" href="mailto:devel@ovirt.org">devel@ovirt.org</a>&gt;, Zheng Sheng ZS
            Zhou/China/IBM@IBMCN</font></tt><br>
        <tt><font size="2">&gt; Date: 2014-07-28 17:22</font></tt><br>
        <tt><font size="2">&gt; Subject: Re: [Kimchi-devel] [PATCH] bug
            fix: Avoid equals sign in VM<br>
            &gt; console URL</font></tt><br>
        <tt><font size="2">&gt; <br>
            &gt; On 07/26/2014 05:01 AM, <a class="moz-txt-link-abbreviated" href="mailto:alinefm@linux.vnet.ibm.com">alinefm@linux.vnet.ibm.com</a>
            wrote:<br>
            &gt; &gt; From: Aline Manera
            <a class="moz-txt-link-rfc2396E" href="mailto:alinefm@linux.vnet.ibm.com">&lt;alinefm@linux.vnet.ibm.com&gt;</a><br>
            &gt; &gt;<br>
            &gt; &gt; &gt;From python documentation,
            base64.urlsafe_b64encode(s) <br>
            &gt; substitutes - instead<br>
            &gt; &gt; of + and _ instead of / in the standard Base64
            alphabet, BUT the result can<br>
            &gt; &gt; still contain = which is not safe in a URL query
            component.<br>
            &gt; &gt; As token value is not decoded nowhere, replace =
            by A<br>
            &gt; also in our kimchi I have try:<br>
            &gt; In [45]: base64.urlsafe_b64encode("abcd")<br>
            &gt; Out[45]: 'YWJjZA=='<br>
            &gt; In [41]: base64.urlsafe_b64encode("abcde")<br>
            &gt; Out[41]: 'YWJjZGU='<br>
            &gt; <br>
            &gt; <br>
            &gt; JS is very cool, it can decode base64 without "="
            padding well<br>
            &gt; kimchi.urlSafeB64Decode("YWJjZA")<br>
            &gt; "abcd"<br>
            &gt; kimchi.urlSafeB64Decode("YWJjZGU")<br>
            &gt; "abcde"<br>
            &gt; <br>
            &gt; we just need in python:<br>
            &gt; In [48]: base64.urlsafe_b64encode("abcd").rstrip("=")<br>
            &gt; Out[48]: 'YWJjZA'<br>
            &gt; <br>
            &gt; </font></tt><br>
        <br>
        <tt><font size="2">A friendly remind: We have to make sure this
            trick also works in IE and Chome.</font></tt><br>
      </p>
    </blockquote>
    Try chrom can work. But No IE environment. <br>
    <blockquote
cite="mid:OFA484BD05.A789300B-ON48257D24.000CD77B-48257D24.000D180D@cn.ibm.com"
      type="cite">
      <p>
        <tt><font size="2"><br>
            &gt; &gt; The problem with equals sign was only identified
            on Spice connections.<br>
            &gt; &gt; noVNC can deal well with that.<br>
            &gt; &gt;<br>
            &gt; &gt; For reference: <a moz-do-not-send="true"
              href="https://docs.python.org/2/library/base64.html">https://docs.python.org/2/library/base64.html</a><br>
            &gt; &gt;<br>
            &gt; &gt; Signed-off-by: Aline Manera
            <a class="moz-txt-link-rfc2396E" href="mailto:alinefm@linux.vnet.ibm.com">&lt;alinefm@linux.vnet.ibm.com&gt;</a><br>
            &gt; &gt; ---<br>
            &gt; &gt; &nbsp; src/kimchi/vnc.py &nbsp; &nbsp; &nbsp; | &nbsp;9 ++++++++-<br>
            &gt; &gt; &nbsp; ui/js/src/kimchi.api.js | 18 ++++++++++++++++--<br>
            &gt; &gt; &nbsp; 2 files changed, 24 insertions(+), 3
            deletions(-)<br>
            &gt; &gt;<br>
            &gt; &gt; diff --git a/src/kimchi/vnc.py b/src/kimchi/vnc.py<br>
            &gt; &gt; index 9380e21..4159049 100644<br>
            &gt; &gt; --- a/src/kimchi/vnc.py<br>
            &gt; &gt; +++ b/src/kimchi/vnc.py<br>
            &gt; &gt; @@ -54,7 +54,14 @@ def new_ws_proxy():<br>
            &gt; &gt;<br>
            &gt; &gt; &nbsp; def add_proxy_token(name, port):<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; with open(os.path.join(WS_TOKENS_DIR, name),
            'w') as f:<br>
            &gt; &gt; - &nbsp; &nbsp; &nbsp; &nbsp;name = base64.urlsafe_b64encode(name)<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;"""<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;From python documentation
            base64.urlsafe_b64encode(s)<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;substitutes - instead of + and _ instead
            of / in the<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;standard Base64 alphabet, BUT the result
            can still<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;contain = which is not safe in a URL
            query component.<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;As token value is not decoded nowhere,
            replace = by A<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;"""<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp;name =
            base64.urlsafe_b64encode(name).replace('=', 'A')<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f.write('%s: localhost:%s' %
            (name.encode('utf-8'), port))<br>
            &gt; &gt;<br>
            &gt; &gt;<br>
            &gt; &gt; diff --git a/ui/js/src/kimchi.api.js
            b/ui/js/src/kimchi.api.js<br>
            &gt; &gt; index 8f5b68f..30360c5 100644<br>
            &gt; &gt; --- a/ui/js/src/kimchi.api.js<br>
            &gt; &gt; +++ b/ui/js/src/kimchi.api.js<br>
            &gt; &gt; @@ -352,7 +352,14 @@ var kimchi = {<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }).done(function() {<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url = '<a class="moz-txt-link-freetext" href="https://">https://</a>' +
            location.hostname + ':' + proxy_port;<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url +=
            "/console.html?url=vnc_auto.html&amp;port=" +<br>
            &gt; proxy_port;<br>
            &gt; &gt; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url += "&amp;path=?token=" +
            kimchi.urlSafeB64Encode(vm);<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * From python documentation
            base64.urlsafe_b64encode(s)<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * substitutes - instead of + and
            _ instead of / in the<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * standard Base64 alphabet, BUT
            the result can still<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * contain = which is not safe in
            a URL query component.<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * As token value is not decoded
            nowhere, replace = by A<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * */<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url += "&amp;path=?token=" +
            kimchi.urlSafeB64Encode<br>
            &gt; (vm).replace(/=/g, 'A');<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url += "&amp;kimchi=" +
            location.port;<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url += '&amp;encrypt=1';<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.open(url);<br>
            &gt; &gt; @@ -377,7 +384,14 @@ var kimchi = {<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url = '<a class="moz-txt-link-freetext" href="https://">https://</a>' +
            location.hostname + ':' + proxy_port;<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url +=
            "/console.html?url=spice.html&amp;port=" + proxy_port;<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url += "&amp;listen=" +
            location.hostname;<br>
            &gt; &gt; - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url += "&amp;token=" +
            kimchi.urlSafeB64Encode(vm);<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * From python documentation
            base64.urlsafe_b64encode(s)<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * substitutes - instead of + and
            _ instead of / in the<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * standard Base64 alphabet, BUT
            the result can still<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * contain = which is not safe in
            a URL query component.<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * As token value is not decoded
            nowhere, replace = by A<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * */<br>
            &gt; &gt; + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url += "&amp;token=" +
            kimchi.urlSafeB64Encode<br>
            &gt; (vm).replace(/=/g, 'A');<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url += "&amp;kimchi=" +
            location.port;<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url += '&amp;encrypt=1';<br>
            &gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.open(url);<br>
            &gt; <br>
            &gt; <br>
            &gt; -- <br>
            &gt; Thanks and best regards!<br>
            &gt; <br>
            &gt; Sheldon Feng(·λΙΩΊΟ)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a><br>
            &gt; IBM Linux Technology Center<br>
            &gt; <br>
          </font></tt>
      </p>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Thanks and best regards!

Sheldon Feng(·λΙΩΊΟ)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
IBM Linux Technology Center</pre>
  </body>
</html>