billboard.js 3.18.0-next.2 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +319 -100
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +10 -9
- package/dist/billboard.pkgd.js +2059 -1625
- package/dist/billboard.pkgd.min.js +23 -22
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +305 -79
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-stanford.js +305 -79
- package/dist/plugin/billboardjs-plugin-stanford.min.js +11 -11
- package/dist/plugin/billboardjs-plugin-tableview.js +305 -79
- package/dist/plugin/billboardjs-plugin-tableview.min.js +6 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +305 -79
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1743 -1528
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2047 -1606
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2048 -1607
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +17 -17
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2049 -1608
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +13 -12
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2050 -1609
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +441 -135
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +416 -102
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +1 -1
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/internals/tooltip.ts +11 -9
- package/src/config/Options/axis/y2.ts +0 -13
- package/src/config/Options/common/legend.ts +1 -0
- package/src/config/Options/common/point.ts +1 -1
- package/src/config/Options/common/tooltip.ts +3 -1
- package/src/module/sanitize.ts +471 -0
- package/src/module/util.ts +1 -131
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.18.0
|
|
8
|
+
* @version 3.18.0
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -100,7 +100,7 @@ var Plugin = /** @class */ (function () {
|
|
|
100
100
|
delete _this[key];
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
|
-
Plugin.version = "3.18.0
|
|
103
|
+
Plugin.version = "3.18.0";
|
|
104
104
|
return Plugin;
|
|
105
105
|
}());
|
|
106
106
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.18.0
|
|
8
|
+
* @version 3.18.0
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -377,7 +377,7 @@ var Plugin = /** @class */ (function () {
|
|
|
377
377
|
delete _this[key];
|
|
378
378
|
});
|
|
379
379
|
};
|
|
380
|
-
Plugin.version = "3.18.0
|
|
380
|
+
Plugin.version = "3.18.0";
|
|
381
381
|
return Plugin;
|
|
382
382
|
}());
|
|
383
383
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.18.0
|
|
8
|
+
* @version 3.18.0
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -441,7 +441,7 @@ var Plugin = /** @class */ (function () {
|
|
|
441
441
|
delete _this[key];
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
|
-
Plugin.version = "3.18.0
|
|
444
|
+
Plugin.version = "3.18.0";
|
|
445
445
|
return Plugin;
|
|
446
446
|
}());
|
|
447
447
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.18.0
|
|
8
|
+
* @version 3.18.0
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -76,119 +76,433 @@ var win = getGlobal();
|
|
|
76
76
|
var doc = win === null || win === void 0 ? void 0 : win.document;
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
80
|
+
* billboard.js project is licensed under the MIT license
|
|
81
|
+
* @ignore
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* HTML/SVG Sanitization module
|
|
85
|
+
* Pure whitelist approach - only explicitly allowed tags, attributes, and protocols pass through
|
|
86
|
+
*/
|
|
87
|
+
// Whitelist of allowed HTML/SVG tags
|
|
88
|
+
var ALLOWED_TAGS = new Set([
|
|
89
|
+
// HTML tags for tooltip/legend templates
|
|
90
|
+
"span",
|
|
91
|
+
"div",
|
|
92
|
+
"p",
|
|
93
|
+
"br",
|
|
94
|
+
"b",
|
|
95
|
+
"i",
|
|
96
|
+
"em",
|
|
97
|
+
"strong",
|
|
98
|
+
"u",
|
|
99
|
+
"s",
|
|
100
|
+
"sub",
|
|
101
|
+
"sup",
|
|
102
|
+
"ul",
|
|
103
|
+
"ol",
|
|
104
|
+
"li",
|
|
105
|
+
"dl",
|
|
106
|
+
"dt",
|
|
107
|
+
"dd",
|
|
108
|
+
"table",
|
|
109
|
+
"thead",
|
|
110
|
+
"tbody",
|
|
111
|
+
"tfoot",
|
|
112
|
+
"tr",
|
|
113
|
+
"th",
|
|
114
|
+
"td",
|
|
115
|
+
"caption",
|
|
116
|
+
"colgroup",
|
|
117
|
+
"col",
|
|
118
|
+
"hr",
|
|
119
|
+
"pre",
|
|
120
|
+
"code",
|
|
121
|
+
"blockquote",
|
|
122
|
+
"a",
|
|
123
|
+
"img",
|
|
124
|
+
// SVG tags for point patterns
|
|
125
|
+
"svg",
|
|
126
|
+
"g",
|
|
127
|
+
"path",
|
|
128
|
+
"circle",
|
|
129
|
+
"ellipse",
|
|
130
|
+
"rect",
|
|
131
|
+
"line",
|
|
132
|
+
"polyline",
|
|
133
|
+
"polygon",
|
|
134
|
+
"text",
|
|
135
|
+
"tspan",
|
|
136
|
+
"textPath",
|
|
137
|
+
"use",
|
|
138
|
+
"defs",
|
|
139
|
+
"symbol",
|
|
140
|
+
"clipPath",
|
|
141
|
+
"mask",
|
|
142
|
+
"linearGradient",
|
|
143
|
+
"radialGradient",
|
|
144
|
+
"stop",
|
|
145
|
+
"pattern",
|
|
146
|
+
"marker",
|
|
147
|
+
"title",
|
|
148
|
+
"desc"
|
|
149
|
+
]);
|
|
150
|
+
// Whitelist of allowed attributes
|
|
151
|
+
var ALLOWED_ATTRS = new Set([
|
|
152
|
+
// Common attributes
|
|
153
|
+
"class",
|
|
154
|
+
"id",
|
|
155
|
+
"style",
|
|
156
|
+
"title",
|
|
157
|
+
"lang",
|
|
158
|
+
"dir",
|
|
159
|
+
// HTML specific
|
|
160
|
+
"href",
|
|
161
|
+
"src",
|
|
162
|
+
"alt",
|
|
163
|
+
"width",
|
|
164
|
+
"height",
|
|
165
|
+
"colspan",
|
|
166
|
+
"rowspan",
|
|
167
|
+
"scope",
|
|
168
|
+
"headers",
|
|
169
|
+
// SVG presentation attributes
|
|
170
|
+
"d",
|
|
171
|
+
"points",
|
|
172
|
+
"x",
|
|
173
|
+
"y",
|
|
174
|
+
"x1",
|
|
175
|
+
"x2",
|
|
176
|
+
"y1",
|
|
177
|
+
"y2",
|
|
178
|
+
"cx",
|
|
179
|
+
"cy",
|
|
180
|
+
"r",
|
|
181
|
+
"rx",
|
|
182
|
+
"ry",
|
|
183
|
+
"dx",
|
|
184
|
+
"dy",
|
|
185
|
+
"viewBox",
|
|
186
|
+
"preserveAspectRatio",
|
|
187
|
+
"transform",
|
|
188
|
+
"fill",
|
|
189
|
+
"fill-opacity",
|
|
190
|
+
"fill-rule",
|
|
191
|
+
"stroke",
|
|
192
|
+
"stroke-width",
|
|
193
|
+
"stroke-opacity",
|
|
194
|
+
"stroke-linecap",
|
|
195
|
+
"stroke-linejoin",
|
|
196
|
+
"stroke-dasharray",
|
|
197
|
+
"stroke-dashoffset",
|
|
198
|
+
"opacity",
|
|
199
|
+
"clip-path",
|
|
200
|
+
"clip-rule",
|
|
201
|
+
"mask",
|
|
202
|
+
"font-family",
|
|
203
|
+
"font-size",
|
|
204
|
+
"font-weight",
|
|
205
|
+
"font-style",
|
|
206
|
+
"text-anchor",
|
|
207
|
+
"dominant-baseline",
|
|
208
|
+
"offset",
|
|
209
|
+
"stop-color",
|
|
210
|
+
"stop-opacity",
|
|
211
|
+
"gradientUnits",
|
|
212
|
+
"gradientTransform",
|
|
213
|
+
"spreadMethod",
|
|
214
|
+
"patternUnits",
|
|
215
|
+
"patternTransform",
|
|
216
|
+
"marker-start",
|
|
217
|
+
"marker-mid",
|
|
218
|
+
"marker-end",
|
|
219
|
+
"markerWidth",
|
|
220
|
+
"markerHeight",
|
|
221
|
+
"refX",
|
|
222
|
+
"refY",
|
|
223
|
+
"xlink:href"
|
|
224
|
+
]);
|
|
225
|
+
// Whitelist of allowed URI protocols
|
|
226
|
+
var ALLOWED_URI_PROTOCOLS = new Set([
|
|
227
|
+
"http:",
|
|
228
|
+
"https:",
|
|
229
|
+
"mailto:"
|
|
230
|
+
]);
|
|
231
|
+
// Attributes that contain URIs
|
|
232
|
+
var URI_ATTRS = new Set(["href", "src", "xlink:href"]);
|
|
233
|
+
// Pre-compiled regex patterns for performance
|
|
234
|
+
var TAG_NAME_REGEX = /^<\/?([a-zA-Z][a-zA-Z0-9]*)/;
|
|
235
|
+
var CLOSING_TAG_REGEX = /^<\/([a-zA-Z][a-zA-Z0-9]*)\s*>$/;
|
|
236
|
+
var OPENING_TAG_REGEX = /^<([a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?)>$/;
|
|
237
|
+
var ATTR_REGEX = /([a-zA-Z][\w:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
238
|
+
var URL_IN_STYLE_REGEX = /url\s*\(\s*["']?([^"')]+)["']?\s*\)/gi;
|
|
239
|
+
// Dangerous CSS patterns
|
|
240
|
+
var DANGEROUS_CSS_PATTERNS = [
|
|
241
|
+
"expression(",
|
|
242
|
+
"behavior:",
|
|
243
|
+
"binding:",
|
|
244
|
+
"@import",
|
|
245
|
+
"@charset",
|
|
246
|
+
"-moz-binding:"
|
|
247
|
+
];
|
|
248
|
+
/**
|
|
249
|
+
* Decode HTML entities in a string
|
|
250
|
+
* @param {string} str String with potential HTML entities
|
|
251
|
+
* @returns {string} Decoded string
|
|
81
252
|
* @private
|
|
82
253
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
lt
|
|
91
|
-
gt
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
254
|
+
function decodeHTMLEntities(str) {
|
|
255
|
+
return str
|
|
256
|
+
// Named entities
|
|
257
|
+
.replace(/:/gi, ":")
|
|
258
|
+
.replace(/&newline;/gi, "\n")
|
|
259
|
+
.replace(/&tab;/gi, "\t")
|
|
260
|
+
.replace(/ /gi, " ")
|
|
261
|
+
.replace(/</gi, "<")
|
|
262
|
+
.replace(/>/gi, ">")
|
|
263
|
+
.replace(/&/gi, "&")
|
|
264
|
+
.replace(/"/gi, "\"")
|
|
265
|
+
.replace(/'/gi, "'")
|
|
266
|
+
// Numeric entities (decimal)
|
|
267
|
+
.replace(/&#(\d+);/gi, function (_, code) { return String.fromCharCode(parseInt(code, 10)); })
|
|
268
|
+
// Numeric entities (hex)
|
|
269
|
+
.replace(/&#x([0-9a-f]+);/gi, function (_, code) { return String.fromCharCode(parseInt(code, 16)); });
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Check if a URI is safe (whitelist approach)
|
|
273
|
+
* @param {string} uri URI to check
|
|
274
|
+
* @returns {boolean} Whether the URI is safe
|
|
275
|
+
* @private
|
|
276
|
+
*/
|
|
277
|
+
function isSafeURI(uri) {
|
|
278
|
+
// Decode HTML entities first to prevent bypass
|
|
279
|
+
var decoded = decodeHTMLEntities(uri).trim();
|
|
280
|
+
// Remove any whitespace/control characters that could be used for bypass
|
|
281
|
+
// eslint-disable-next-line no-control-regex
|
|
282
|
+
var normalized = decoded.replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
|
|
283
|
+
// Empty or fragment-only URIs are safe
|
|
284
|
+
if (!normalized || normalized.startsWith("#")) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
// Relative paths are safe
|
|
288
|
+
if (normalized.startsWith("/") ||
|
|
289
|
+
normalized.startsWith("./") ||
|
|
290
|
+
normalized.startsWith("../") ||
|
|
291
|
+
!normalized.includes(":")) {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
// Check if protocol is in whitelist
|
|
295
|
+
var colonIndex = normalized.indexOf(":");
|
|
296
|
+
if (colonIndex > 0) {
|
|
297
|
+
var protocol = normalized.substring(0, colonIndex + 1);
|
|
298
|
+
return ALLOWED_URI_PROTOCOLS.has(protocol);
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Check if a style value is safe (whitelist approach)
|
|
304
|
+
* @param {string} style Style attribute value
|
|
305
|
+
* @returns {string|null} Sanitized style or null if unsafe
|
|
306
|
+
* @private
|
|
307
|
+
*/
|
|
308
|
+
function sanitizeStyleValue(style) {
|
|
309
|
+
// Decode HTML entities first
|
|
310
|
+
var decoded = decodeHTMLEntities(style);
|
|
311
|
+
// Remove any control characters
|
|
312
|
+
// eslint-disable-next-line no-control-regex
|
|
313
|
+
var cleaned = decoded.replace(/[\u0000-\u001f]/g, "");
|
|
314
|
+
// Check for url() - only allow safe URIs inside
|
|
315
|
+
URL_IN_STYLE_REGEX.lastIndex = 0;
|
|
316
|
+
var match;
|
|
317
|
+
while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) {
|
|
318
|
+
if (!isSafeURI(match[1])) {
|
|
319
|
+
return null;
|
|
150
320
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
|
|
321
|
+
}
|
|
322
|
+
// Check for dangerous CSS patterns (expression, behavior, etc.)
|
|
323
|
+
var normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
|
|
324
|
+
for (var _i = 0, DANGEROUS_CSS_PATTERNS_1 = DANGEROUS_CSS_PATTERNS; _i < DANGEROUS_CSS_PATTERNS_1.length; _i++) {
|
|
325
|
+
var pattern = DANGEROUS_CSS_PATTERNS_1[_i];
|
|
326
|
+
if (normalizedLower.includes(pattern)) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return style;
|
|
331
|
+
}
|
|
332
|
+
// Lookup table for encoding dangerous characters in attribute values
|
|
333
|
+
var ATTR_ENCODE_MAP = {
|
|
334
|
+
"\"": """,
|
|
335
|
+
"'": "'",
|
|
336
|
+
"`": "`"
|
|
337
|
+
};
|
|
338
|
+
var ATTR_ENCODE_REGEX = /["'`]/g;
|
|
339
|
+
/**
|
|
340
|
+
* Encode dangerous characters in attribute values to HTML entities
|
|
341
|
+
* This prevents attribute injection attacks where quotes/backticks break out of the attribute context
|
|
342
|
+
* @param {string} value Attribute value
|
|
343
|
+
* @returns {string} Encoded value
|
|
344
|
+
* @private
|
|
345
|
+
*/
|
|
346
|
+
function encodeAttrValue(value) {
|
|
347
|
+
return value.replace(ATTR_ENCODE_REGEX, function (char) { return ATTR_ENCODE_MAP[char]; });
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Sanitize attribute value using whitelist approach
|
|
351
|
+
* @param {string} name Attribute name
|
|
352
|
+
* @param {string} value Attribute value
|
|
353
|
+
* @param {boolean} wasUnquoted Whether the value was originally unquoted
|
|
354
|
+
* @returns {string|null} Sanitized value if safe, null if should be removed
|
|
355
|
+
* @private
|
|
356
|
+
*/
|
|
357
|
+
function sanitizeAttrValue(name, value, wasUnquoted) {
|
|
358
|
+
if (wasUnquoted === void 0) { wasUnquoted = false; }
|
|
359
|
+
// Check URI attributes with whitelist
|
|
360
|
+
if (URI_ATTRS.has(name)) {
|
|
361
|
+
if (!isSafeURI(value)) {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
// Encode dangerous characters in URI values to prevent attribute injection
|
|
365
|
+
return wasUnquoted ? encodeAttrValue(value) : value;
|
|
366
|
+
}
|
|
367
|
+
// Check style attribute
|
|
368
|
+
if (name === "style") {
|
|
369
|
+
var sanitizedStyle = sanitizeStyleValue(value);
|
|
370
|
+
if (sanitizedStyle === null) {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
// Encode dangerous characters in style values
|
|
374
|
+
return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
|
|
375
|
+
}
|
|
376
|
+
// For other attributes, check for embedded event handlers
|
|
377
|
+
var decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
|
|
378
|
+
if (/\bon\w+=/.test(decoded)) {
|
|
379
|
+
return null;
|
|
380
|
+
}
|
|
381
|
+
// Encode dangerous characters to prevent attribute injection
|
|
382
|
+
return wasUnquoted ? encodeAttrValue(value) : value;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Extract tag name from a tag string
|
|
386
|
+
* Returns null if not a valid tag format
|
|
387
|
+
* @param {string} tag Tag string starting with <
|
|
388
|
+
* @returns {string|null} Lowercase tag name or null
|
|
389
|
+
* @private
|
|
390
|
+
*/
|
|
391
|
+
function extractTagName(tag) {
|
|
392
|
+
// Must start with < followed immediately by letter (no spaces allowed)
|
|
393
|
+
var match = tag.match(TAG_NAME_REGEX);
|
|
394
|
+
return match ? match[1].toLowerCase() : null;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Check if a tag is in the whitelist
|
|
398
|
+
* @param {string} tag Tag string
|
|
399
|
+
* @returns {boolean} Whether tag is allowed
|
|
400
|
+
* @private
|
|
401
|
+
*/
|
|
402
|
+
function isAllowedTag(tag) {
|
|
403
|
+
var tagName = extractTagName(tag);
|
|
404
|
+
return tagName !== null && ALLOWED_TAGS.has(tagName);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Sanitize a single HTML/SVG tag (only called for allowed tags)
|
|
408
|
+
* @param {string} fullTag The full tag string including < and >
|
|
409
|
+
* @returns {string} Sanitized tag
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
function sanitizeTag(fullTag) {
|
|
413
|
+
// Closing tag
|
|
414
|
+
var closingMatch = fullTag.match(CLOSING_TAG_REGEX);
|
|
415
|
+
if (closingMatch) {
|
|
416
|
+
return "</".concat(closingMatch[1].toLowerCase(), ">");
|
|
417
|
+
}
|
|
418
|
+
// Opening tag
|
|
419
|
+
var openingMatch = fullTag.match(OPENING_TAG_REGEX);
|
|
420
|
+
if (!openingMatch) {
|
|
421
|
+
return "";
|
|
422
|
+
}
|
|
423
|
+
var tagName = openingMatch[1], attrString = openingMatch[2], selfClose = openingMatch[3];
|
|
424
|
+
var lowerTagName = tagName.toLowerCase();
|
|
425
|
+
// Parse and filter attributes, preserving original quote style
|
|
426
|
+
var allowedAttrs = [];
|
|
427
|
+
ATTR_REGEX.lastIndex = 0;
|
|
428
|
+
var attrMatch;
|
|
429
|
+
while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
|
|
430
|
+
var attrName = attrMatch[1].toLowerCase();
|
|
431
|
+
var doubleQuotedValue = attrMatch[2];
|
|
432
|
+
var singleQuotedValue = attrMatch[3];
|
|
433
|
+
var unquotedValue = attrMatch[4];
|
|
434
|
+
// Skip event handlers (on*)
|
|
435
|
+
if (attrName.startsWith("on")) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
// Determine original quote style and value
|
|
439
|
+
var attrValue = void 0;
|
|
440
|
+
var quoteChar = void 0;
|
|
441
|
+
if (doubleQuotedValue !== undefined) {
|
|
442
|
+
attrValue = doubleQuotedValue;
|
|
443
|
+
quoteChar = "\"";
|
|
444
|
+
}
|
|
445
|
+
else if (singleQuotedValue !== undefined) {
|
|
446
|
+
attrValue = singleQuotedValue;
|
|
447
|
+
quoteChar = "'";
|
|
448
|
+
}
|
|
449
|
+
else if (unquotedValue !== undefined) {
|
|
450
|
+
attrValue = unquotedValue;
|
|
451
|
+
quoteChar = "\"";
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
// Boolean attribute (no value)
|
|
455
|
+
if (ALLOWED_ATTRS.has(attrName)) {
|
|
456
|
+
allowedAttrs.push(attrName);
|
|
457
|
+
}
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (ALLOWED_ATTRS.has(attrName)) {
|
|
461
|
+
var wasUnquoted = unquotedValue !== undefined;
|
|
462
|
+
var sanitizedValue = sanitizeAttrValue(attrName, attrValue, wasUnquoted);
|
|
463
|
+
if (sanitizedValue !== null) {
|
|
464
|
+
allowedAttrs.push("".concat(attrName, "=").concat(quoteChar).concat(sanitizedValue).concat(quoteChar));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
var attrsStr = allowedAttrs.length > 0 ? " ".concat(allowedAttrs.join(" ")) : "";
|
|
469
|
+
var selfCloseStr = selfClose ? "/>" : ">";
|
|
470
|
+
return "<".concat(lowerTagName).concat(attrsStr).concat(selfCloseStr);
|
|
471
|
+
}
|
|
157
472
|
/**
|
|
158
473
|
* Sanitize HTML string to prevent XSS attacks
|
|
159
|
-
*
|
|
160
|
-
* Handles encoded characters (HTML entities, Unicode escapes) to prevent bypass attacks
|
|
474
|
+
* Pure whitelist approach - allowed tags are sanitized, others are escaped
|
|
161
475
|
* @param {string} str Target string value
|
|
162
|
-
* @returns {string} Sanitized string with
|
|
476
|
+
* @returns {string} Sanitized string with only allowed elements
|
|
163
477
|
* @private
|
|
164
478
|
*/
|
|
165
479
|
function sanitize(str) {
|
|
166
|
-
|
|
167
|
-
if (!isString(str) || !str || str.indexOf("<") === -1) {
|
|
480
|
+
if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
|
|
168
481
|
return str;
|
|
169
482
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
//
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
.replace(_sanitize.rx.controlChar, "")
|
|
181
|
-
.replace(_sanitize.rx.tags, "")
|
|
182
|
-
.replace(_sanitize.rx.eventHandler, ""); // 4. Remove event handlers
|
|
183
|
-
// 5. Remove dangerous URIs (javascript:, data:, vbscript:)
|
|
184
|
-
result = _sanitize.removeDangerousUris(result);
|
|
185
|
-
// Safety check to prevent infinite loops
|
|
186
|
-
if (++iterations >= _sanitize.MAX_ITERATIONS) {
|
|
187
|
-
break;
|
|
483
|
+
// Single pass: sanitize allowed tags, escape disallowed ones
|
|
484
|
+
// Also match orphaned fragments like "ipt>" from broken tags
|
|
485
|
+
return str.replace(/<\/?[^>]*>|[^<>\s]+>/g, function (match) {
|
|
486
|
+
// Remove HTML comments
|
|
487
|
+
if (match.startsWith("<!--")) {
|
|
488
|
+
return "";
|
|
489
|
+
}
|
|
490
|
+
// Orphaned fragment (e.g., "ipt>") → escape '>'
|
|
491
|
+
if (!match.startsWith("<")) {
|
|
492
|
+
return match.slice(0, -1) + ">";
|
|
188
493
|
}
|
|
189
|
-
|
|
190
|
-
|
|
494
|
+
// Allowed tag → sanitize attributes
|
|
495
|
+
if (isAllowedTag(match)) {
|
|
496
|
+
return sanitizeTag(match);
|
|
497
|
+
}
|
|
498
|
+
// Disallowed tag → escape all '<' to prevent execution
|
|
499
|
+
return match.replace(/</g, "<");
|
|
500
|
+
});
|
|
191
501
|
}
|
|
502
|
+
|
|
503
|
+
var isNumber = function (v) { return typeof v === "number"; };
|
|
504
|
+
var isDefined = function (v) { return typeof v !== "undefined"; };
|
|
505
|
+
var isObjectType = function (v) { return typeof v === "object"; };
|
|
192
506
|
// emulate event
|
|
193
507
|
({
|
|
194
508
|
mouse: (function () {
|
|
@@ -328,7 +642,7 @@ var Plugin = /** @class */ (function () {
|
|
|
328
642
|
delete _this[key];
|
|
329
643
|
});
|
|
330
644
|
};
|
|
331
|
-
Plugin.version = "3.18.0
|
|
645
|
+
Plugin.version = "3.18.0";
|
|
332
646
|
return Plugin;
|
|
333
647
|
}());
|
|
334
648
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.18.0
|
|
8
|
+
* @version 3.18.0
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -204,7 +204,7 @@ var Plugin = /** @class */ (function () {
|
|
|
204
204
|
delete _this[key];
|
|
205
205
|
});
|
|
206
206
|
};
|
|
207
|
-
Plugin.version = "3.18.0
|
|
207
|
+
Plugin.version = "3.18.0";
|
|
208
208
|
return Plugin;
|
|
209
209
|
}());
|
|
210
210
|
|
package/package.json
CHANGED
|
@@ -440,7 +440,7 @@ export default class ChartInternal {
|
|
|
440
440
|
$el.defs = $el.svg.append("defs");
|
|
441
441
|
|
|
442
442
|
if (hasAxis) {
|
|
443
|
-
["id", "idXAxis", "idYAxis", "
|
|
443
|
+
["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
|
|
444
444
|
$$.appendClip($el.defs, state.clip[v]);
|
|
445
445
|
});
|
|
446
446
|
}
|