Skip to content

Commit b408072

Browse files
lnt: profile encoding and how objects are stripped
Change-Id: I954d942ff54ca482ec8f4b53d70433f7f404159b
1 parent a0f98b5 commit b408072

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lnt/server/ui/profile_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def v4_profile_ajax_getCodeForFunction():
110110
runid = request.args.get('runid')
111111
testid = request.args.get('testid')
112112
f_enc = request.args.get('f')
113-
f = base64.b64decode(f_enc)
113+
f = base64.b64decode(f_enc).decode("utf-8")
114114

115115
profileDir = current_app.old_config.profileDir
116116

lnt/server/ui/static/lnt_profile.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,15 @@ function startsWith(string, startString) {
451451
return string.substr(0, startString.length) === startString;
452452
}
453453

454+
/**
455+
* Unicode to ASCII (encode data to Base64)
456+
* @param {string} data
457+
* @return {string}
458+
*/
459+
function utoa(data) {
460+
return btoa(unescape(encodeURIComponent(data)));
461+
}
462+
454463
Profile.prototype = {
455464
reset: function() {
456465
$(this.element).empty();
@@ -470,7 +479,7 @@ Profile.prototype = {
470479
},
471480

472481
_fetch_and_display: function(fname, then) {
473-
fname_encoded = btoa (fname)
482+
fname_encoded = utoa (fname)
474483
this.function_name = fname_encoded;
475484
var this_ = this;
476485
$.ajax(g_urls.getCodeForFunction, {
@@ -1078,7 +1087,10 @@ function FunctionTypeahead(element, options) {
10781087
// FIXME: the item isn't passed in as json any more, it's
10791088
// been rendered. Lame. Hack around this by splitting apart
10801089
// the ','-concatenated 2-tuple again.
1081-
fname = item.split(',')[0];
1090+
// tamar: with C++ symbols demangled we have natural ,s in the
1091+
// string so we can't blindly lop off ,. Instead lets just
1092+
// do a safer substring on ,[object Object].
1093+
fname = item.substr(0, item.length - ",[object Object]".length);
10821094

10831095
options.updated(fname);
10841096
return fname;

0 commit comments

Comments
 (0)