From 6d660f387b097ec131e05a75035782c93fa451cd Mon Sep 17 00:00:00 2001 From: zefie Date: Mon, 11 Aug 2025 15:26:04 -0400 Subject: [PATCH] more optimizations --- .../includes/ServiceVault/wtv-author/scrapbook.js | 2 +- .../includes/ServiceVault/wtv-author/styles.js | 4 ++-- .../includes/ServiceVault/wtv-disk/sync.js | 2 +- .../ServiceVault/wtv-flashrom/get-lc2-page.js | 4 ++-- .../wtv-flashrom/initiate-lc2-download.js | 4 ++-- .../includes/ServiceVault/wtv-flashrom/willie.js | 4 ++-- .../includes/ServiceVault/wtv-mail/readmail.js | 2 +- .../includes/ServiceVault/wtv-news/news.js | 2 +- .../ServiceVault/wtv-proxy/map/catchall.js | 2 +- .../wtv-register/ValidateReviewAccountInfo.js | 4 ++-- .../includes/ServiceVault/wtv-setup/get.js | 2 +- .../includes/ServiceVault/wtv-setup/set-bg.js | 2 +- .../wtv-setup/validate-bg-song-category.js | 4 ++-- .../includes/classes/WTVClientSessionData.js | 10 +++++----- zefie_wtvp_minisrv/includes/classes/WTVShared.js | 14 +++++++------- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/scrapbook.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/scrapbook.js index 2d5102c6..f1684dee 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/scrapbook.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/scrapbook.js @@ -214,7 +214,7 @@ if (files.length > 0) { for (let i = start; i < Math.min(files.length, start + 6); i++) { url = "wtv-tricks:/view-scrapbook-image?id=" + files[i]; if (request_headers.query.addMediaURL) { - url = unescape(request_headers.query.addMediaURL) + "&scrapbookID=" + files[i]; + url = decodeURIComponent(request_headers.query.addMediaURL) + "&scrapbookID=" + files[i]; } data += ` diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/styles.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/styles.js index 22c93a45..cc082d51 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/styles.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-author/styles.js @@ -118,13 +118,13 @@ vspace=0
+href="wtv-author:/styles?tmplClass=11&docName=${docName}&styleName=${encodeURIComponent(styleName)}&pageNum=${(page > 0) ? (page - 1) : (pages.length - 1)}#minus" id=minus>
${page + 1} of ${pages.length}
+href="wtv-author:/styles?tmplClass=11&docName=${docName}&styleName=${encodeURIComponent(styleName)}&pageNum=${(page+1 < pages.length) ? (page + 1) : 0}#plus" id=plus>
diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js index 6ef77fb3..f3845ddb 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js @@ -85,7 +85,7 @@ if (request_headers['wtv-request-type'] == 'download') { case "GET": var get_url = service_name + ":/" + update_list[k].location + "?"; if (update_list[k].compress === false) get_url += "dont_compress=true&"; - if (update_list[k].type) get_url += "content_type=" + escape(update_list[k].type) + "&"; + if (update_list[k].type) get_url += "content_type=" + encodeURIComponent(update_list[k].type) + "&"; wtvdl.get(update_list[k].file.replace(diskmap_group_data.base, ""), update_list[k].file, get_url, diskmap_group_name, update_list[k].checksum, update_list[k].uncompressed_size || null, update_list[k].original_filename) break; } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js index 0a6b5bda..dee0c093 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/get-lc2-page.js @@ -43,8 +43,8 @@ async function processLC2DownloadPage(flashrom_info, headers, numparts = null) { if (!flashrom_info.is_last_part) { flashrom_info.next_rompath = request_headers.request_url.replace( - escape(request_headers.query.path), - escape(flashrom_info.next_rompath.replace(service_name + ":/", "")) + encodeURIComponent(request_headers.query.path), + encodeURIComponent(flashrom_info.next_rompath.replace(service_name + ":/", "")) ); } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/initiate-lc2-download.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/initiate-lc2-download.js index 90b8d7de..78c0f43c 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/initiate-lc2-download.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/initiate-lc2-download.js @@ -4,8 +4,8 @@ if (request_headers.query.path) { var url = service_name + ":/get-lc2-page?path=" + request_headers.query.path; var romtype = session_data.get("wtv-client-rom-type"); if (romtype == "bf0app") { - url = "client:updateflash?ipaddr=" + minisrv_config.services[service_name].host + "&port=" + minisrv_config.services[service_name].port + "&path=" + escape(service_name + ":/" + request_headers.query.path); - if (request_headers.query.numparts) url += escape("?numparts=" + request_headers.query.numparts); + url = "client:updateflash?ipaddr=" + minisrv_config.services[service_name].host + "&port=" + minisrv_config.services[service_name].port + "&path=" + encodeURIComponent(service_name + ":/" + request_headers.query.path); + if (request_headers.query.numparts) url += encodeURIComponent("?numparts=" + request_headers.query.numparts); } else { if (request_headers.query.numparts) url += "&numparts=" + request_headers.query.numparts; } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/willie.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/willie.js index 665b3f7a..4074feb3 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/willie.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-flashrom/willie.js @@ -11,7 +11,7 @@ if (request_headers.query.vflash) delete request_headers.query.vflash; if (request_headers.query.pflash) delete request_headers.query.pflash; for (const [key, value] of Object.entries(request_headers.query)) { - proxy_query += "&" + key + "=" + escape(value); + proxy_query += "&" + key + "=" + encodeURIComponent(value); } if (!minisrv_config.services[service_name].use_zefie_server) { @@ -20,7 +20,7 @@ if (!minisrv_config.services[service_name].use_zefie_server) { var options = { host: "roms.minisrv.dev", - path: "/?minisrv=true&service_name="+escape(service_name)+"&pflash=" + session_data.get("wtv-client-rom-type") + proxy_query, + path: "/?minisrv=true&service_name="+encodeURIComponent(service_name)+"&pflash=" + session_data.get("wtv-client-rom-type") + proxy_query, timeout: 5000, method: 'GET' } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-mail/readmail.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-mail/readmail.js index 15eb4fdc..65a46c67 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-mail/readmail.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-mail/readmail.js @@ -249,7 +249,7 @@ From: `; if (message.from_name != message.from_addr) { - data += `${wtvshared.htmlEntitize(message.from_addr)} (${wtvshared.htmlEntitize(message.from_name)})`; + data += `${wtvshared.htmlEntitize(message.from_addr)} (${wtvshared.htmlEntitize(message.from_name)})`; } else { data += `${wtvshared.htmlEntitize(message.from_addr)}`; } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-news/news.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-news/news.js index 0585fd34..1fc3bc50 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-news/news.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-news/news.js @@ -592,7 +592,7 @@ ${strftime("%a, %b %e, %Y, %I:%M%P", new Date(Date.parse(response.article.header From: `; if (message.from_name != message.from_addr) { - data += `${wtvshared.htmlEntitize(message.from_addr)} `; + data += `${wtvshared.htmlEntitize(message.from_addr)} `; } else { data += `${wtvshared.htmlEntitize(response.article.headers.FROM)}`; } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/map/catchall.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/map/catchall.js index ba40ed1c..81154d62 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/map/catchall.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-proxy/map/catchall.js @@ -59,7 +59,7 @@ lib.get(targetUrl, (res) => { } else { var idx = data.indexOf('
'); data = data.substring(0, idx); - var redirectUrl = `${service_name}:/proxy?err=${escape(data)}`; + var redirectUrl = `${service_name}:/proxy?err=${encodeURIComponent(data)}`; sendToClient(socket, {'Status': 302, 'Location': redirectUrl}, ''); } }); diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-register/ValidateReviewAccountInfo.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-register/ValidateReviewAccountInfo.js index e517fb91..70893f9d 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-register/ValidateReviewAccountInfo.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-register/ValidateReviewAccountInfo.js @@ -15,8 +15,8 @@ if (!request_headers.query.registering || data = errpage[1]; } else { if (request_headers.query['Change']) { - var changeUrl = "wtv-register:/ValidateAgreement?registering=" + escape(request_headers.query.registering) + "&subscriber_name=" + escape(request_headers.query.subscriber_name); - changeUrl += "&subscriber_username=" + escape(request_headers.query.subscriber_username) + "&subscriber_contact=" + escape(request_headers.query.subscriber_contact) + "&subscriber_contact_method=" + escape(request_headers.query.subscriber_contact_method) + var changeUrl = "wtv-register:/ValidateAgreement?registering=" + encodeURIComponent(request_headers.query.registering) + "&subscriber_name=" + encodeURIComponent(request_headers.query.subscriber_name); + changeUrl += "&subscriber_username=" + encodeURIComponent(request_headers.query.subscriber_username) + "&subscriber_contact=" + encodeURIComponent(request_headers.query.subscriber_contact) + "&subscriber_contact_method=" + encodeURIComponent(request_headers.query.subscriber_contact_method); var errpage = wtvshared.doRedirect(changeUrl); headers = errpage[0]; data = errpage[1]; diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/get.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/get.js index e131e711..9ca342d2 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/get.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/get.js @@ -46,7 +46,7 @@ Content-Type: text/html`; data = ""; Object.keys(settings_obj).forEach(function (k, v) { - data += k + "=" + escape(settings_obj[k]) + "&"; + data += k + "=" + encodeURIComponent(settings_obj[k]) + "&"; }); data = data.substring(0, (data.length - 1)); diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/set-bg.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/set-bg.js index 1bbf2430..57c9c871 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/set-bg.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/set-bg.js @@ -110,7 +110,7 @@ Choose the songs that you'd like to include. var songTitle = musicList[k]['title']; if (songTitle.length > strLenLimit) songTitle = musicList[k]['title'].substr(0, strLenLimit - 3) + "..."; if (musicList.length > 14) data += ''; - data += `${songTitle} + data += `${songTitle} `; if (musicList.length > 14) data += ''; songsListed++; diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/validate-bg-song-category.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/validate-bg-song-category.js index d48c3017..adfb834e 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/validate-bg-song-category.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-setup/validate-bg-song-category.js @@ -31,8 +31,8 @@ if (request_headers.query && session_data) { var qraw_split = qraw[i].split("="); if (qraw_split.length == 2) { var k = qraw_split[0]; - if (k == "enableCategory") music_obj['enableCategories'].push(unescape(qraw[i].split("=")[1].replace(/\+/g, "%20"))); - if (k == "enableSong") music_obj['enableSongs'].push(unescape(qraw[i].split("=")[1].replace(/\+/g, "%20"))); + if (k == "enableCategory") music_obj['enableCategories'].push(decodeURIComponent(qraw[i].split("=")[1].replace(/\+/g, "%20"))); + if (k == "enableSong") music_obj['enableSongs'].push(decodeURIComponent(qraw[i].split("=")[1].replace(/\+/g, "%20"))); } } } diff --git a/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js b/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js index 7d8b21f1..2651d178 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVClientSessionData.js @@ -549,10 +549,10 @@ class WTVClientSessionData { } else { if (path && expires && data) { var cookie_data = {}; - cookie_data['cookie'] = unescape(data); - cookie_data['expires'] = unescape(expires); - cookie_data['path'] = unescape(path); - cookie_data['domain'] = unescape(domain); + cookie_data['cookie'] = decodeURIComponent(data); + cookie_data['expires'] = decodeURIComponent(expires); + cookie_data['path'] = decodeURIComponent(path); + cookie_data['domain'] = decodeURIComponent(domain); } else { return false; } @@ -608,7 +608,7 @@ class WTVClientSessionData { /* var outstring = ""; Object.keys(cookie_data).forEach(function (k) { - outstring += k + "=" + escape(cookie_data[k]) + "&"; + outstring += k + "=" + encodeURIComponent(cookie_data[k]) + "&"; }); return outstring.slice(0, outstring.length - 1); */ diff --git a/zefie_wtvp_minisrv/includes/classes/WTVShared.js b/zefie_wtvp_minisrv/includes/classes/WTVShared.js index 027a2bbb..e3b9ae24 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVShared.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVShared.js @@ -1548,13 +1548,13 @@ class clientShowAlert { */ getURL() { let url = "client:ShowAlert?"; - if (this.message) url += `message=${escape(this.message)}&`; - if (this.buttonlabel1) url += `buttonlabel1=${escape(this.buttonlabel1)}&`; - if (this.buttonaction1) url += `buttonaction1=${escape(this.buttonaction1)}&`; - if (this.buttonlabel2) url += `buttonlabel2=${escape(this.buttonlabel2)}&`; - if (this.buttonaction2) url += `buttonaction2=${escape(this.buttonaction2)}&`; - if (this.image) url += `image=${escape(this.image)}&`; - if (this.sound) url += `sound=${escape(this.sound)}&`; + if (this.message) url += `message=${encodeURIComponent(this.message)}&`; + if (this.buttonlabel1) url += `buttonlabel1=${encodeURIComponent(this.buttonlabel1)}&`; + if (this.buttonaction1) url += `buttonaction1=${encodeURIComponent(this.buttonaction1)}&`; + if (this.buttonlabel2) url += `buttonlabel2=${encodeURIComponent(this.buttonlabel2)}&`; + if (this.buttonaction2) url += `buttonaction2=${encodeURIComponent(this.buttonaction2)}&`; + if (this.image) url += `image=${encodeURIComponent(this.image)}&`; + if (this.sound) url += `sound=${encodeURIComponent(this.sound)}&`; if (this.noback) url += "noback=true&"; return url.slice(0, -1); }