From 87f09ffec1a7f14eb8a05e0c368858241a7de580 Mon Sep 17 00:00:00 2001 From: zefie Date: Fri, 10 Nov 2023 15:04:48 -0500 Subject: [PATCH] reverse atob and btoa to proper standard (damn dyslexia) --- .../includes/classes/WTVAuthor.js | 8 +++--- .../includes/classes/WTVFavorites.js | 4 +-- .../includes/classes/WTVShared.js | 26 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/classes/WTVAuthor.js b/zefie_wtvp_minisrv/includes/classes/WTVAuthor.js index ab37eacd..dc4efffb 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVAuthor.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVAuthor.js @@ -274,7 +274,7 @@ ${thisblock.title} block += "" block += `
- +
@@ -470,8 +470,8 @@ this.fs.writeFile(destDir + this.wtvclient.session_store.subscriber_username + ' break; case "clipart": - this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + atob(thisblock.photo).substr(0, atob(thisblock.photo).lastIndexOf("/")), { recursive: true }) - this.fs.copyFile('includes/ServiceVault/wtv-author/' + atob(thisblock.photo), destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + atob(thisblock.photo), (err) => { + this.fs.mkdirSync(destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + btoa(thisblock.photo).substr(0, btoa(thisblock.photo).lastIndexOf("/")), { recursive: true }) + this.fs.copyFile('includes/ServiceVault/wtv-author/' + btoa(thisblock.photo), destDir + this.wtvclient.session_store.subscriber_username + '/' + pagedata.publishname + "/" + btoa(thisblock.photo), (err) => { if (err) throw err; }); block = `

` @@ -486,7 +486,7 @@ ${thisblock.title} ` block += ` diff --git a/zefie_wtvp_minisrv/includes/classes/WTVFavorites.js b/zefie_wtvp_minisrv/includes/classes/WTVFavorites.js index dd5318f1..4a3c5f9b 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVFavorites.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVFavorites.js @@ -83,7 +83,7 @@ class WTVFavorites { var self = this; if (folder_templates[folder]) { Object.keys(folder_templates[folder]).forEach(function (k) { - self.createFavorite(folder_templates[folder][k].title, folder_templates[folder][k].url, folder, (folder_templates[folder][k].image_type == "image/wtv-bitmap") ? atob(folder_templates[folder][k].image) : folder_templates[folder][k].image, folder_templates[folder][k].image_type); + self.createFavorite(folder_templates[folder][k].title, folder_templates[folder][k].url, folder, (folder_templates[folder][k].image_type == "image/wtv-bitmap") ? btoa(folder_templates[folder][k].image) : folder_templates[folder][k].image, folder_templates[folder][k].image_type); }) } } @@ -140,7 +140,7 @@ class WTVFavorites { var favoritefile = favoriteid + this.favFileExt; var favoritefileout = folderpath + favoritefile; if (imagetype != "url") - image = btoa(image); + image = atob(image); title = decodeURIComponent(title).replaceAll("+", " "); url = decodeURIComponent(url) diff --git a/zefie_wtvp_minisrv/includes/classes/WTVShared.js b/zefie_wtvp_minisrv/includes/classes/WTVShared.js index 69c1df57..07295b62 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVShared.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVShared.js @@ -79,26 +79,26 @@ class WTVShared { } } - /** - * CryptoJS implmentation of Base64 Decoder - * @param {string} a Base64 String - * @return {string} Decoded string - */ - atob(a) { - const CryptoJS = require('crypto-js'); - const enc = CryptoJS.enc.Base64.parse(a); - return CryptoJS.enc.Utf8.stringify(enc) - } - /** * CryptoJS implmentation of Base64 Encoder * @param {string} b String to encode * @returns {string} Base64 encoded string */ + atob(a) { + const CryptoJS = require('crypto-js'); + const enc = CryptoJS.enc.Utf8.parse(a); // encodedWord Array object + return CryptoJS.enc.Base64.stringify(enc); + } + + /** + * CryptoJS implmentation of Base64 Decoder + * @param {string} a Base64 String + * @return {string} Decoded string + */ btoa(b) { const CryptoJS = require('crypto-js'); - const enc = CryptoJS.enc.Utf8.parse(b); // encodedWord Array object - return CryptoJS.enc.Base64.stringify(enc); + const enc = CryptoJS.enc.Base64.parse(b); + return CryptoJS.enc.Utf8.stringify(enc) } /**
- +