Fixed Telegram proxy issue (#4703)

Ylian Saint-Hilaire committed Nov 2, 2022 at 13:59 UTC 60af01a1653eccf417e160f84f8dfa4a19eb19cb
2 files changed +6 -3
common.js
+5 -2
@@ -142,9 +142,12 @@ module.exports.zeroPad = function(num, c) { if (c == null) { c = 2; } var s = '0
142
143 // Lowercase all the names in a object recursively
144 // Allow for exception keys, child of exceptions will not get lower-cased.
145 -module.exports.objKeysToLower = function (obj, exceptions) {
145 +// Exceptions is an array of "keyname" or "parent\keyname"
146 +module.exports.objKeysToLower = function (obj, exceptions, parent) {
147 for (var i in obj) {
147 - if ((typeof obj[i] == 'object') && ((exceptions == null) || (exceptions.indexOf(i.toLowerCase()) == -1))) { module.exports.objKeysToLower(obj[i], exceptions); } // LowerCase all key names in the child object
148 + if ((typeof obj[i] == 'object') && ((exceptions == null) || (exceptions.indexOf(i.toLowerCase()) == -1)) && ((parent != null) && (exceptions.indexOf(parent.toLowerCase() + '/' + i.toLowerCase()) == -1))) {
149 + module.exports.objKeysToLower(obj[i], exceptions, i); // LowerCase all key names in the child object
150 + }
151 if (i.toLowerCase() !== i) { obj[i.toLowerCase()] = obj[i]; delete obj[i]; } // LowerCase all key names
152 }
153 return obj;
meshcentral.js
+1 -1
@@ -1202,7 +1202,7 @@ function CreateMeshCentralServer(config, args) {
1202 for (i in args) { config2.settings[i] = args[i]; }
1203
1204 // Lower case all keys in the config file
1205 - common.objKeysToLower(config2, ['ldapoptions', 'defaultuserwebstate', 'forceduserwebstate', 'httpheaders']);
1205 + common.objKeysToLower(config2, ['ldapoptions', 'defaultuserwebstate', 'forceduserwebstate', 'httpheaders', 'telegram/proxy']);
1206
1207 // Grab some of the values from the original config.json file if present.
1208 config2['mysql'] = config['mysql'];