soiz1 commited on
Commit
978a3b4
·
verified ·
1 Parent(s): 05e36be

Update src/extensions/jwArray/index.js

Browse files
Files changed (1) hide show
  1. src/extensions/jwArray/index.js +16 -7
src/extensions/jwArray/index.js CHANGED
@@ -12,14 +12,23 @@ let arrayLimit = 2 ** 32
12
  * @returns {string}
13
  */
14
  function formatNumber(x) {
15
- if (x >= 1e6) {
16
- return x.toExponential(4)
17
- } else {
18
- x = Math.floor(x * 1000) / 1000
19
- return x.toFixed(Math.min(3, (String(x).split('.')[1] || '').length))
20
- }
21
  }
22
 
 
 
 
 
 
 
 
 
 
23
  function clampIndex(x) {
24
  return Math.min(Math.max(x, 0), arrayLimit)
25
  }
@@ -78,7 +87,7 @@ class ArrayType {
78
  case "boolean":
79
  return x ? "true" : "false"
80
  case "string":
81
- return `"${Cast.toString(x)}"`
82
  }
83
  } catch {}
84
  return "?"
 
12
  * @returns {string}
13
  */
14
  function formatNumber(x) {
15
+ if (x >= 1e6) {
16
+ return x.toExponential(4)
17
+ } else {
18
+ x = Math.floor(x * 1000) / 1000
19
+ return x.toFixed(Math.min(3, (String(x).split('.')[1] || '').length))
20
+ }
21
  }
22
 
23
+ const escapeHTML = unsafe => {
24
+ return unsafe
25
+ .replaceAll("&", "&")
26
+ .replaceAll("<", "&lt;")
27
+ .replaceAll(">", "&gt;")
28
+ .replaceAll('"', "&quot;")
29
+ .replaceAll("'", "&#039;")
30
+ };
31
+
32
  function clampIndex(x) {
33
  return Math.min(Math.max(x, 0), arrayLimit)
34
  }
 
87
  case "boolean":
88
  return x ? "true" : "false"
89
  case "string":
90
+ return `"${escapeHTML(Cast.toString(x))}"`
91
  }
92
  } catch {}
93
  return "?"