1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Speeddial: decode initialScript data as Utf8

Summary:
BUG: 406095

Solution based on:
https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_4_%E2%80%93_escaping_the_string_before_encoding_it

Test Plan: Add webpage with title which contains Utf8 character (e.g. ľščťžýáíéúäô) into speeddial

Reviewers: #falkon, drosca

Reviewed By: #falkon, drosca

Subscribers: falkon, drosca

Tags: #falkon

Differential Revision: https://phabricator.kde.org/D27081
This commit is contained in:
Juraj Oravec 2020-02-01 02:35:43 +01:00
parent 1cecd14fd0
commit 4b7a38680b

View File

@ -8,6 +8,12 @@ var scriptData = {};
var editingId = -1;
var ignoreNextChanged = false;
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function emitChanged(pages)
{
ignoreNextChanged = true;
@ -46,6 +52,7 @@ function configureSpeedDial()
$('#fadeOverlay2').click(function() { $(this).fadeOut('slow'); });
$('#settingsBox').click(function(event) { event.stopPropagation(); });
}
function escapeTitle(title) {
title = title.replace(/"/g, '"');
title = title.replace(/'/g, ''');
@ -448,7 +455,7 @@ function init() {
$('#fadeOverlay').click();
});
var pages = JSON.parse(atob(scriptData.initialScript));
var pages = JSON.parse(b64DecodeUnicode(scriptData.initialScript));
for (var i = 0; i < pages.length; ++i) {
var page = pages[i];
addBox(page.url, page.title, page.img);