MCPcopy Index your code
hub / github.com/prettydiff/prettydiff / security

Function security

api/prettydiff-webtool.ts:115–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113 ? ""
114 : page.getAttribute("id"),
115 security = function dom_load_security():void {
116 const scripts:HTMLCollectionOf<HTMLScriptElement> = document.getElementsByTagName("script"),
117 exclusions:string[] = [
118 "js/webtool.js",
119 "browser-demo.js",
120 "node_modules/ace-builds"
121 ],
122 len:number = scripts.length,
123 exlen:number = exclusions.length;
124 let a:number = 0,
125 b:number = 0,
126 src:string = "";
127 // this prevents errors, but it also means you are executing too early.
128 if (len > 0) {
129 do {
130 src = scripts[a].getAttribute("src");
131 if (src === null) {
132 break;
133 }
134 if (src.indexOf("?") > 0) {
135 src = src.slice(0, src.indexOf("?"));
136 }
137 b = 0;
138 do {
139 if (src.indexOf(exclusions[b]) > -1) {
140 break;
141 }
142 b = b + 1;
143 } while (b < exlen);
144 if (b === exlen) {
145 break;
146 }
147 a = a + 1;
148 } while (a < len);
149 if (a < len) {
150 let warning:HTMLDivElement = document.createElement("div");
151 warning.setAttribute("id", "security-warning");
152 warning.innerHTML = `<h1>Warning</h1><h2>This page contains unauthorized script and may be a security risk.</h2><code>${(src === null) ? scripts[a].innerHTML : src}</code>`;
153 document.getElementsByTagName("body")[0].insertBefore(warning, document.getElementsByTagName("body")[0].firstChild);
154 }
155 }
156 };
157 if (pages === "webtool") {
158 let a:number = 0,
159 x:HTMLInputElement,

Callers 1

loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected