mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
MeshMessenger Fixes.
This commit is contained in:
parent
a7ea8fead5
commit
05b93303f5
12 changed files with 130 additions and 28 deletions
|
@ -17,7 +17,29 @@ import Keyboard from "../core/input/keyboard.js";
|
|||
import RFB from "../core/rfb.js";
|
||||
import * as WebUtil from "./webutil.js";
|
||||
|
||||
function parseUriArgs() { var href = window.document.location.href; if (href.endsWith('#')) { href = href.substring(0, href.length - 1); } var name, r = {}, parsedUri = href.split(/[\?&|\=]/); parsedUri.splice(0, 1); for (x in parsedUri) { switch (x % 2) { case 0: { name = decodeURIComponent(parsedUri[x]); break; } case 1: { r[name] = decodeURIComponent(parsedUri[x]); var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } break; } default: { break; } } } return r; }
|
||||
// String validation
|
||||
function isAlphaNumeric(str) { return (str.match(/^[A-Za-z0-9]+$/) != null); };
|
||||
function isSafeString(str) { return ((typeof str == 'string') && (str.indexOf('<') == -1) && (str.indexOf('>') == -1) && (str.indexOf('&') == -1) && (str.indexOf('"') == -1) && (str.indexOf('\'') == -1) && (str.indexOf('+') == -1) && (str.indexOf('(') == -1) && (str.indexOf(')') == -1) && (str.indexOf('#') == -1) && (str.indexOf('%') == -1) && (str.indexOf(':') == -1) && (str.indexOf('-') == -1)) };
|
||||
|
||||
// Parse URL arguments, only keep safe values
|
||||
function parseUriArgs() {
|
||||
var href = window.document.location.href;
|
||||
if (href.endsWith('#')) { href = href.substring(0, href.length - 1); }
|
||||
var name, r = {}, parsedUri = href.split(/[\?&|\=]/);
|
||||
parsedUri.splice(0, 1);
|
||||
for (x in parsedUri) {
|
||||
switch (x % 2) {
|
||||
case 0: { name = decodeURIComponent(parsedUri[x]); break; }
|
||||
case 1: {
|
||||
r[name] = decodeURIComponent(parsedUri[x]);
|
||||
if (!isSafeString(r[name])) { delete r[name]; } else { var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } }
|
||||
break;
|
||||
} default: { break; }
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
var urlargs = parseUriArgs();
|
||||
|
||||
const UI = {
|
||||
|
|
2
public/scripts/common-0.0.1-min.js
vendored
2
public/scripts/common-0.0.1-min.js
vendored
|
@ -1 +1 @@
|
|||
function Q(t){return document.getElementById(t)}function QS(t){try{return Q(t).style}catch(t){}}function QE(t,r){try{Q(t).disabled=!r}catch(t){}}function QV(t,r){try{QS(t).display=r?"":"none"}catch(t){}}function QA(t,r){Q(t).innerHTML+=r}function QH(t,r){Q(t).innerHTML=r}function QC(t){try{return Q(t).classList}catch(t){}}function inputBoxFocus(t){Q(t).focus();var r=Q(t).value;Q(t).value="",Q(t).value=r}function ReadShort(t,r){return(t.charCodeAt(r)<<8)+t.charCodeAt(r+1)}function ReadShortX(t,r){return(t.charCodeAt(r+1)<<8)+t.charCodeAt(r)}function ReadInt(t,r){return 16777216*t.charCodeAt(r)+(t.charCodeAt(r+1)<<16)+(t.charCodeAt(r+2)<<8)+t.charCodeAt(r+3)}function ReadSInt(t,r){return(t.charCodeAt(r)<<24)+(t.charCodeAt(r+1)<<16)+(t.charCodeAt(r+2)<<8)+t.charCodeAt(r+3)}function ReadIntX(t,r){return 16777216*t.charCodeAt(r+3)+(t.charCodeAt(r+2)<<16)+(t.charCodeAt(r+1)<<8)+t.charCodeAt(r)}function ShortToStr(t){return String.fromCharCode(t>>8&255,255&t)}function ShortToStrX(t){return String.fromCharCode(255&t,t>>8&255)}function IntToStr(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}function IntToStrX(t){return String.fromCharCode(255&t,t>>8&255,t>>16&255,t>>24&255)}function MakeToArray(t){return t&&null!=t&&"object"!=typeof t?[t]:t}function SplitArray(t){return t.split(",")}function Clone(t){return JSON.parse(JSON.stringify(t))}function EscapeHtml(t){return"string"==typeof t?t.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""").replace(/'/g,"'"):"boolean"==typeof t?t:"number"==typeof t?t:void 0}function EscapeHtmlBreaks(t){return"string"==typeof t?t.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""").replace(/'/g,"'").replace(/\r/g,"<br />").replace(/\n/g,"").replace(/\t/g," "):"boolean"==typeof t?t:"number"==typeof t?t:void 0}function ArrayElementMove(t,r,n){t.splice(n,0,t.splice(r,1)[0])}function ObjectToStringEx(t,r){var n="";if(0!=t&&(!t||null==t))return"(Null)";if(t instanceof Array)for(var e in t)n+="<br />"+gap(r)+"Item #"+e+": "+ObjectToStringEx(t[e],r+1);else if(t instanceof Object)for(var e in t)n+="<br />"+gap(r)+e+" = "+ObjectToStringEx(t[e],r+1);else n+=EscapeHtml(t);return n}function ObjectToStringEx2(t,r){var n="";if(0!=t&&(!t||null==t))return"(Null)";if(t instanceof Array)for(var e in t)n+="\r\n"+gap2(r)+"Item #"+e+": "+ObjectToStringEx2(t[e],r+1);else if(t instanceof Object)for(var e in t)n+="\r\n"+gap2(r)+e+" = "+ObjectToStringEx2(t[e],r+1);else n+=EscapeHtml(t);return n}function gap(t){for(var r="",n=0;n<4*t;n++)r+=" ";return r}function gap2(t){for(var r="",n=0;n<4*t;n++)r+=" ";return r}function ObjectToString(t){return ObjectToStringEx(t,0)}function ObjectToString2(t){return ObjectToStringEx2(t,0)}function hex2rstr(t){if("string"!=typeof t||0==t.length)return"";for(var r,n="",e=(""+t).match(/../g);r=e.shift();)n+=String.fromCharCode("0x"+r);return n}function char2hex(t){return(t+256).toString(16).substr(-2).toUpperCase()}function rstr2hex(t){var r,n="";for(r=0;r<t.length;r++)n+=char2hex(t.charCodeAt(r));return n}function encode_utf8(t){return unescape(encodeURIComponent(t))}function decode_utf8(t){return decodeURIComponent(escape(t))}function data2blob(t){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return new Blob([new Uint8Array(r)])}function utf2blob(t){for(var r=[],n=unescape(encodeURIComponent(t)),e=0;e<n.length;e++)r.push(n.charCodeAt(e));return new Blob([new Uint8Array(r)])}function random(t){return Math.floor(Math.random()*t)}function trademarks(t){return t.replace(/\(R\)/g,"®").replace(/\(TM\)/g,"™")}function zeroPad(t,r){null==r&&(r=2);var n="00000000"+t;return n.substr(n.length-r)}String.prototype.startsWith||(String.prototype.startsWith=function(t){return 0===this.lastIndexOf(t,0)}),String.prototype.endsWith||(String.prototype.endsWith=function(t){return-1!==this.indexOf(t,this.length-t.length)})
|
||||
function Q(t){return document.getElementById(t)}function QS(t){try{return Q(t).style}catch(t){}}function QE(t,n){try{Q(t).disabled=!n}catch(t){}}function QV(t,n){try{QS(t).display=n?"":"none"}catch(t){}}function QA(t,n){Q(t).innerHTML+=n}function QH(t,n){Q(t).innerHTML=n}function QC(t){try{return Q(t).classList}catch(t){}}function inputBoxFocus(t){Q(t).focus();var n=Q(t).value;Q(t).value="",Q(t).value=n}function ReadShort(t,n){return(t.charCodeAt(n)<<8)+t.charCodeAt(n+1)}function ReadShortX(t,n){return(t.charCodeAt(n+1)<<8)+t.charCodeAt(n)}function ReadInt(t,n){return 16777216*t.charCodeAt(n)+(t.charCodeAt(n+1)<<16)+(t.charCodeAt(n+2)<<8)+t.charCodeAt(n+3)}function ReadSInt(t,n){return(t.charCodeAt(n)<<24)+(t.charCodeAt(n+1)<<16)+(t.charCodeAt(n+2)<<8)+t.charCodeAt(n+3)}function ReadIntX(t,n){return 16777216*t.charCodeAt(n+3)+(t.charCodeAt(n+2)<<16)+(t.charCodeAt(n+1)<<8)+t.charCodeAt(n)}function ShortToStr(t){return String.fromCharCode(t>>8&255,255&t)}function ShortToStrX(t){return String.fromCharCode(255&t,t>>8&255)}function IntToStr(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}function IntToStrX(t){return String.fromCharCode(255&t,t>>8&255,t>>16&255,t>>24&255)}function MakeToArray(t){return t&&null!=t&&"object"!=typeof t?[t]:t}function SplitArray(t){return t.split(",")}function Clone(t){return JSON.parse(JSON.stringify(t))}function EscapeHtml(t){return"string"==typeof t?t.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""").replace(/'/g,"'"):"boolean"==typeof t?t:"number"==typeof t?t:void 0}function EscapeHtmlBreaks(t){return"string"==typeof t?t.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/"/g,""").replace(/'/g,"'").replace(/\r/g,"<br />").replace(/\n/g,"").replace(/\t/g," "):"boolean"==typeof t?t:"number"==typeof t?t:void 0}function ArrayElementMove(t,n,r){t.splice(r,0,t.splice(n,1)[0])}function ObjectToStringEx(t,n){var r="";if(0!=t&&(!t||null==t))return"(Null)";if(t instanceof Array)for(var e in t)r+="<br />"+gap(n)+"Item #"+e+": "+ObjectToStringEx(t[e],n+1);else if(t instanceof Object)for(var e in t)r+="<br />"+gap(n)+e+" = "+ObjectToStringEx(t[e],n+1);else r+=EscapeHtml(t);return r}function ObjectToStringEx2(t,n){var r="";if(0!=t&&(!t||null==t))return"(Null)";if(t instanceof Array)for(var e in t)r+="\r\n"+gap2(n)+"Item #"+e+": "+ObjectToStringEx2(t[e],n+1);else if(t instanceof Object)for(var e in t)r+="\r\n"+gap2(n)+e+" = "+ObjectToStringEx2(t[e],n+1);else r+=EscapeHtml(t);return r}function gap(t){for(var n="",r=0;r<4*t;r++)n+=" ";return n}function gap2(t){for(var n="",r=0;r<4*t;r++)n+=" ";return n}function ObjectToString(t){return ObjectToStringEx(t,0)}function ObjectToString2(t){return ObjectToStringEx2(t,0)}function hex2rstr(t){if("string"!=typeof t||0==t.length)return"";for(var n,r="",e=(""+t).match(/../g);n=e.shift();)r+=String.fromCharCode("0x"+n);return r}function char2hex(t){return(t+256).toString(16).substr(-2).toUpperCase()}function rstr2hex(t){var n,r="";for(n=0;n<t.length;n++)r+=char2hex(t.charCodeAt(n));return r}function encode_utf8(t){return unescape(encodeURIComponent(t))}function decode_utf8(t){return decodeURIComponent(escape(t))}function data2blob(t){for(var n=new Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return new Blob([new Uint8Array(n)])}function utf2blob(t){for(var n=[],r=unescape(encodeURIComponent(t)),e=0;e<r.length;e++)n.push(r.charCodeAt(e));return new Blob([new Uint8Array(n)])}function random(t){return Math.floor(Math.random()*t)}function trademarks(t){return t.replace(/\(R\)/g,"®").replace(/\(TM\)/g,"™")}function zeroPad(t,n){null==n&&(n=2);var r="00000000"+t;return r.substr(r.length-n)}function isAlphaNumeric(t){return null!=t.match(/^[A-Za-z0-9]+$/)}function isSafeString(t){return"string"==typeof t&&-1==t.indexOf("<")&&-1==t.indexOf(">")&&-1==t.indexOf("&")&&-1==t.indexOf('"')&&-1==t.indexOf("'")&&-1==t.indexOf("+")&&-1==t.indexOf("(")&&-1==t.indexOf(")")&&-1==t.indexOf("#")&&-1==t.indexOf("%")&&-1==t.indexOf(":")&&-1==t.indexOf("-")}function parseUriArgs(){var t=window.document.location.href;t.endsWith("#")&&(t=t.substring(0,t.length-1));var n,r={},e=t.split(/[\?&|\=]/);for(o in e.splice(0,1),e)switch(o%2){case 0:n=decodeURIComponent(e[o]);break;case 1:if(r[n]=decodeURIComponent(e[o]),isSafeString(r[n])){var o=parseInt(r[n]);o==r[n]&&(r[n]=o)}else delete r[n]}return r}String.prototype.startsWith||(String.prototype.startsWith=function(t){return 0===this.lastIndexOf(t,0)}),String.prototype.endsWith||(String.prototype.endsWith=function(t){return-1!==this.indexOf(t,this.length-t.length)})
|
|
@ -110,4 +110,24 @@ function trademarks(x) { return x.replace(/\(R\)/g, '®').replace(/\(TM\)/g,
|
|||
function zeroPad(num, c) { if (c == null) { c = 2; } var s = "00000000" + num; return s.substr(s.length - c); }
|
||||
|
||||
// String validation
|
||||
function isAlphaNumeric(str) { return (str.match(/^[A-Za-z0-9]+$/) != null); };
|
||||
function isAlphaNumeric(str) { return (str.match(/^[A-Za-z0-9]+$/) != null); };
|
||||
function isSafeString(str) { return ((typeof str == 'string') && (str.indexOf('<') == -1) && (str.indexOf('>') == -1) && (str.indexOf('&') == -1) && (str.indexOf('"') == -1) && (str.indexOf('\'') == -1) && (str.indexOf('+') == -1) && (str.indexOf('(') == -1) && (str.indexOf(')') == -1) && (str.indexOf('#') == -1) && (str.indexOf('%') == -1) && (str.indexOf(':') == -1) && (str.indexOf('-') == -1)) };
|
||||
|
||||
// Parse URL arguments, only keep safe values
|
||||
function parseUriArgs() {
|
||||
var href = window.document.location.href;
|
||||
if (href.endsWith('#')) { href = href.substring(0, href.length - 1); }
|
||||
var name, r = {}, parsedUri = href.split(/[\?&|\=]/);
|
||||
parsedUri.splice(0, 1);
|
||||
for (x in parsedUri) {
|
||||
switch (x % 2) {
|
||||
case 0: { name = decodeURIComponent(parsedUri[x]); break; }
|
||||
case 1: {
|
||||
r[name] = decodeURIComponent(parsedUri[x]);
|
||||
if (!isSafeString(r[name])) { delete r[name]; } else { var x = parseInt(r[name]); if (x == r[name]) { r[name] = x; } }
|
||||
break;
|
||||
} default: { break; }
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue