fix consent/notify messages with multiple placeholders #7037
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
May 19, 2025 at 10:27 UTC
022f85efe72878a58798e6727df926cd424e9b79
1 file changed
+19
-19
agents/meshcore.js
+19
-19
@@ -2314,11 +2314,11 @@ function terminal_end()
2314
2315
function terminal_consent_ask(ws) {
2316
ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
2317
- var consentMessage = currentTranslation['terminalConsent'].replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username);
2317
+ var consentMessage = currentTranslation['terminalConsent'].replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username);
2318
var consentTitle = 'MeshCentral';
2319
if (ws.httprequest.soptions != null) {
2320
if (ws.httprequest.soptions.consentTitle != null) { consentTitle = ws.httprequest.soptions.consentTitle; }
2321
- if (ws.httprequest.soptions.consentMsgTerminal != null) { consentMessage = ws.httprequest.soptions.consentMsgTerminal.replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username); }
2321
+ if (ws.httprequest.soptions.consentMsgTerminal != null) { consentMessage = ws.httprequest.soptions.consentMsgTerminal.replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username); }
2322
}
2323
if (process.platform == 'win32') {
2324
var enhanced = false;
@@ -2417,12 +2417,12 @@ function terminal_promise_connection_resolved(term)
2417
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 2))
2418
{
2419
// User Notifications is required
2420
- var notifyMessage = currentTranslation['terminalNotify'].replace('{0}', this.ws.httprequest.realname ? this.ws.httprequest.realname : this.ws.httprequest.username);
2420
+ var notifyMessage = currentTranslation['terminalNotify'].replaceAll('{0}', this.ws.httprequest.realname ? this.ws.httprequest.realname : this.ws.httprequest.username);
2421
var notifyTitle = "MeshCentral";
2422
if (this.ws.httprequest.soptions != null)
2423
{
2424
if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
2425
- if (this.ws.httprequest.soptions.notifyMsgTerminal != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgTerminal.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
2425
+ if (this.ws.httprequest.soptions.notifyMsgTerminal != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgTerminal.replaceAll('{0}', this.ws.httprequest.realname).replaceAll('{1}', this.ws.httprequest.username); }
2426
}
2427
try { require('toaster').Toast(notifyTitle, notifyMessage); } catch (ex) { }
2428
}
@@ -2646,7 +2646,7 @@ function tunnel_kvm_end()
2646
this.httprequest.desktop.kvm.users.splice(i, 1);
2647
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
2648
this.httprequest.desktop.kvm.connectionBar.close();
2649
- this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.httprequest.privacybartext.replace('{0}', this.httprequest.desktop.kvm.rusers.join(', ')).replace('{1}', this.httprequest.desktop.kvm.users.join(', ')).replace(/'/g, "\\'\\"), require('MeshAgent')._tsid, color_options);
2649
+ this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.httprequest.privacybartext.replaceAll('{0}', this.httprequest.desktop.kvm.rusers.join(', ')).replaceAll('{1}', this.httprequest.desktop.kvm.users.join(', ')).replace(/'/g, "\\'\\"), require('MeshAgent')._tsid, color_options);
2650
this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
2651
this.httprequest.desktop.kvm.connectionBar.on('close', function ()
2652
{
@@ -2682,11 +2682,11 @@ function kvm_consent_ok(ws) {
2682
if (ws.httprequest.consent && (ws.httprequest.consent & 1)){
2683
// User Notifications is required
2684
MeshServerLogEx(35, null, "Started remote desktop with toast notification (" + ws.httprequest.remoteaddr + ")", ws.httprequest);
2685
- var notifyMessage = currentTranslation['desktopNotify'].replace('{0}', ws.httprequest.realname);
2685
+ var notifyMessage = currentTranslation['desktopNotify'].replaceAll('{0}', ws.httprequest.realname);
2686
var notifyTitle = "MeshCentral";
2687
if (ws.httprequest.soptions != null) {
2688
if (ws.httprequest.soptions.notifyTitle != null) { notifyTitle = ws.httprequest.soptions.notifyTitle; }
2689
- if (ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = ws.httprequest.soptions.notifyMsgDesktop.replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username); }
2689
+ if (ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = ws.httprequest.soptions.notifyMsgDesktop.replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username); }
2690
}
2691
try { require('toaster').Toast(notifyTitle, notifyMessage, ws.tsid); } catch (ex) { }
2692
} else {
@@ -2699,7 +2699,7 @@ function kvm_consent_ok(ws) {
2699
ws.httprequest.desktop.kvm.connectionBar.close();
2700
}
2701
try {
2702
- ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(ws.httprequest.privacybartext.replace('{0}', ws.httprequest.desktop.kvm.rusers.join(', ')).replace('{1}', ws.httprequest.desktop.kvm.users.join(', ')).replace(/'/g, "\\'\\"), require('MeshAgent')._tsid, color_options);
2702
+ ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(ws.httprequest.privacybartext.replaceAll('{0}', ws.httprequest.desktop.kvm.rusers.join(', ')).replaceAll('{1}', ws.httprequest.desktop.kvm.users.join(', ')).replace(/'/g, "\\'\\"), require('MeshAgent')._tsid, color_options);
2703
MeshServerLogEx(31, null, "Remote Desktop Connection Bar Activated/Updated (" + ws.httprequest.remoteaddr + ")", ws.httprequest);
2704
} catch (ex) {
2705
MeshServerLogEx(32, null, "Remote Desktop Connection Bar Failed or not Supported (" + ws.httprequest.remoteaddr + ")", ws.httprequest);
@@ -2733,11 +2733,11 @@ function kvm_consent_ok(ws) {
2733
function kvm_consent_ask(ws){
2734
// Send a console message back using the console channel, "\n" is supported.
2735
ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
2736
- var consentMessage = currentTranslation['desktopConsent'].replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username);
2736
+ var consentMessage = currentTranslation['desktopConsent'].replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username);
2737
var consentTitle = 'MeshCentral';
2738
if (ws.httprequest.soptions != null) {
2739
if (ws.httprequest.soptions.consentTitle != null) { consentTitle = ws.httprequest.soptions.consentTitle; }
2740
- if (ws.httprequest.soptions.consentMsgDesktop != null) { consentMessage = ws.httprequest.soptions.consentMsgDesktop.replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username); }
2740
+ if (ws.httprequest.soptions.consentMsgDesktop != null) { consentMessage = ws.httprequest.soptions.consentMsgDesktop.replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username); }
2741
}
2742
var pr;
2743
if (process.platform == 'win32') {
@@ -2794,12 +2794,12 @@ function kvm_consentpromise_resolved(always)
2794
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1))
2795
{
2796
// User Notifications is required
2797
- var notifyMessage = currentTranslation['desktopNotify'].replace('{0}', this.ws.httprequest.realname);
2797
+ var notifyMessage = currentTranslation['desktopNotify'].replaceAll('{0}', this.ws.httprequest.realname);
2798
var notifyTitle = "MeshCentral";
2799
if (this.ws.httprequest.soptions != null)
2800
{
2801
if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
2802
- if (this.ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgDesktop.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
2802
+ if (this.ws.httprequest.soptions.notifyMsgDesktop != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgDesktop.replaceAll('{0}', this.ws.httprequest.realname).replaceAll('{1}', this.ws.httprequest.username); }
2803
}
2804
try { require('toaster').Toast(notifyTitle, notifyMessage, tsid); } catch (ex) { }
2805
}
@@ -2813,7 +2813,7 @@ function kvm_consentpromise_resolved(always)
2813
}
2814
try
2815
{
2816
- this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.ws.httprequest.privacybartext.replace('{0}', this.ws.httprequest.desktop.kvm.rusers.join(', ')).replace('{1}', this.ws.httprequest.desktop.kvm.users.join(', ')).replace(/'/g, "\\'\\"), require('MeshAgent')._tsid, color_options);
2816
+ this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')(this.ws.httprequest.privacybartext.replaceAll('{0}', this.ws.httprequest.desktop.kvm.rusers.join(', ')).replaceAll('{1}', this.ws.httprequest.desktop.kvm.users.join(', ')).replace(/'/g, "\\'\\"), require('MeshAgent')._tsid, color_options);
2817
MeshServerLogEx(31, null, "Remote Desktop Connection Bar Activated/Updated (" + this.ws.httprequest.remoteaddr + ")", this.ws.httprequest);
2818
} catch (ex)
2819
{
@@ -2856,11 +2856,11 @@ function files_consent_ok(ws){
2856
if (ws.httprequest.consent && (ws.httprequest.consent & 4)) {
2857
// User Notifications is required
2858
MeshServerLogEx(42, null, "Started remote files with toast notification (" + ws.httprequest.remoteaddr + ")", ws.httprequest);
2859
- var notifyMessage = currentTranslation['fileNotify'].replace('{0}', ws.httprequest.realname);
2859
+ var notifyMessage = currentTranslation['fileNotify'].replaceAll('{0}', ws.httprequest.realname);
2860
var notifyTitle = "MeshCentral";
2861
if (ws.httprequest.soptions != null) {
2862
if (ws.httprequest.soptions.notifyTitle != null) { notifyTitle = ws.httprequest.soptions.notifyTitle; }
2863
- if (ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = ws.httprequest.soptions.notifyMsgFiles.replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username); }
2863
+ if (ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = ws.httprequest.soptions.notifyMsgFiles.replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username); }
2864
}
2865
try { require('toaster').Toast(notifyTitle, notifyMessage); } catch (ex) { }
2866
} else {
@@ -2872,12 +2872,12 @@ function files_consent_ok(ws){
2872
function files_consent_ask(ws){
2873
// Send a console message back using the console channel, "\n" is supported.
2874
ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: "Waiting for user to grant access...", msgid: 1 }));
2875
- var consentMessage = currentTranslation['fileConsent'].replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username);
2875
+ var consentMessage = currentTranslation['fileConsent'].replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username);
2876
var consentTitle = 'MeshCentral';
2877
2878
if (ws.httprequest.soptions != null) {
2879
if (ws.httprequest.soptions.consentTitle != null) { consentTitle = ws.httprequest.soptions.consentTitle; }
2880
- if (ws.httprequest.soptions.consentMsgFiles != null) { consentMessage = ws.httprequest.soptions.consentMsgFiles.replace('{0}', ws.httprequest.realname).replace('{1}', ws.httprequest.username); }
2880
+ if (ws.httprequest.soptions.consentMsgFiles != null) { consentMessage = ws.httprequest.soptions.consentMsgFiles.replaceAll('{0}', ws.httprequest.realname).replaceAll('{1}', ws.httprequest.username); }
2881
}
2882
var pr;
2883
if (process.platform == 'win32') {
@@ -2923,12 +2923,12 @@ function files_consentpromise_resolved(always)
2923
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 4))
2924
{
2925
// User Notifications is required
2926
- var notifyMessage = currentTranslation['fileNotify'].replace('{0}', this.ws.httprequest.realname);
2926
+ var notifyMessage = currentTranslation['fileNotify'].replaceAll('{0}', this.ws.httprequest.realname);
2927
var notifyTitle = "MeshCentral";
2928
if (this.ws.httprequest.soptions != null)
2929
{
2930
if (this.ws.httprequest.soptions.notifyTitle != null) { notifyTitle = this.ws.httprequest.soptions.notifyTitle; }
2931
- if (this.ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgFiles.replace('{0}', this.ws.httprequest.realname).replace('{1}', this.ws.httprequest.username); }
2931
+ if (this.ws.httprequest.soptions.notifyMsgFiles != null) { notifyMessage = this.ws.httprequest.soptions.notifyMsgFiles.replaceAll('{0}', this.ws.httprequest.realname).replaceAll('{1}', this.ws.httprequest.username); }
2932
}
2933
try { require('toaster').Toast(notifyTitle, notifyMessage); } catch (ex) { }
2934
}