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.
Files changed (51) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +319 -100
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +10 -9
  5. package/dist/billboard.pkgd.js +2059 -1625
  6. package/dist/billboard.pkgd.min.js +23 -22
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +305 -79
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  11. package/dist/plugin/billboardjs-plugin-stanford.js +305 -79
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +11 -11
  13. package/dist/plugin/billboardjs-plugin-tableview.js +305 -79
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +6 -5
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +305 -79
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1743 -1528
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2047 -1606
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2048 -1607
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +17 -17
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2049 -1608
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +13 -12
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2050 -1609
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
  27. package/dist/theme/dark.css +1 -1
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +1 -1
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +1 -1
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +1 -1
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +1 -1
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/billboard.js +441 -135
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +416 -102
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +1 -1
  44. package/src/ChartInternal/ChartInternal.ts +1 -1
  45. package/src/ChartInternal/internals/tooltip.ts +11 -9
  46. package/src/config/Options/axis/y2.ts +0 -13
  47. package/src/config/Options/common/legend.ts +1 -0
  48. package/src/config/Options/common/point.ts +1 -1
  49. package/src/config/Options/common/tooltip.ts +3 -1
  50. package/src/module/sanitize.ts +471 -0
  51. 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-next.2
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-next.2";
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-next.2
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-next.2";
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-next.2
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-next.2";
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-next.2
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
- * Private sanitization utilities
80
- * Encapsulates all XSS prevention patterns and helper functions
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
- var _sanitize = (function () {
84
- var DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
85
- // HTML entity character code map (for decoding)
86
- var ENTITY_MAP = {
87
- quot: 34,
88
- amp: 38,
89
- apos: 39,
90
- lt: 60,
91
- gt: 62,
92
- nbsp: 160,
93
- iexcl: 161,
94
- cent: 162,
95
- pound: 163,
96
- curren: 164,
97
- yen: 165
98
- };
99
- // Angle bracket codes (< and >) - never decode these to prevent tag bypass
100
- var LT_CODE = 60;
101
- var GT_CODE = 62;
102
- // Maximum sanitization iterations to prevent infinite loops
103
- var MAX_ITERATIONS = 10;
104
- // Regular expressions (compiled once for performance)
105
- var rx = {
106
- tags: new RegExp("<(".concat(DANGEROUS_TAGS, ")\\b[\\s\\S]*?>([\\s\\S]*?<\\/(").concat(DANGEROUS_TAGS, ")\\s*>)?"), "gi"),
107
- htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
108
- // eslint-disable-next-line no-control-regex
109
- controlChar: /[\x00-\x1F\x7F]/g,
110
- eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
111
- dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
112
- dangerousProtocol: /^(javascript|data|vbscript):/
113
- };
114
- return {
115
- ENTITY_MAP: ENTITY_MAP,
116
- LT_CODE: LT_CODE,
117
- GT_CODE: GT_CODE,
118
- MAX_ITERATIONS: MAX_ITERATIONS,
119
- rx: rx,
120
- /**
121
- * Decode HTML entities to prevent bypass attacks
122
- * @param {string} str String with potential HTML entities
123
- * @returns {string} Decoded string
124
- */
125
- decodeEntities: function (str) {
126
- return str.replace(rx.htmlEntity, function (match, hex, dec, named) {
127
- var code = hex ?
128
- parseInt(hex, 16) :
129
- dec ?
130
- parseInt(dec, 10) :
131
- named ?
132
- ENTITY_MAP[named.toLowerCase()] || 0 :
133
- 0;
134
- // Never decode angle brackets to prevent tag bypass
135
- return code && code !== LT_CODE && code !== GT_CODE ?
136
- String.fromCharCode(code) :
137
- match;
138
- });
139
- },
140
- /**
141
- * Remove dangerous URI protocols from attribute values
142
- * @param {string} str String to sanitize
143
- * @returns {string} Sanitized string
144
- */
145
- removeDangerousUris: function (str) {
146
- return str.replace(rx.dangerousUri, function (match, attr, quote, value) {
147
- var normalized = value.toLowerCase().replace(/\s/g, "");
148
- return rx.dangerousProtocol.test(normalized) ? "".concat(attr, "=").concat(quote).concat(quote) : match;
149
- });
254
+ function decodeHTMLEntities(str) {
255
+ return str
256
+ // Named entities
257
+ .replace(/&colon;/gi, ":")
258
+ .replace(/&newline;/gi, "\n")
259
+ .replace(/&tab;/gi, "\t")
260
+ .replace(/&nbsp;/gi, " ")
261
+ .replace(/&lt;/gi, "<")
262
+ .replace(/&gt;/gi, ">")
263
+ .replace(/&amp;/gi, "&")
264
+ .replace(/&quot;/gi, "\"")
265
+ .replace(/&apos;/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 isString = function (v) { return typeof v === "string"; };
154
- var isNumber = function (v) { return typeof v === "number"; };
155
- var isDefined = function (v) { return typeof v !== "undefined"; };
156
- var isObjectType = function (v) { return typeof v === "object"; };
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
+ "\"": "&quot;",
335
+ "'": "&#39;",
336
+ "`": "&#96;"
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
- * Uses blacklist approach with repeated application to prevent nested tag bypass
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 dangerous elements removed
476
+ * @returns {string} Sanitized string with only allowed elements
163
477
  * @private
164
478
  */
165
479
  function sanitize(str) {
166
- // Early return for non-string, empty string, or string without HTML
167
- if (!isString(str) || !str || str.indexOf("<") === -1) {
480
+ if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
168
481
  return str;
169
482
  }
170
- var result = str;
171
- var prev;
172
- var iterations = 0;
173
- // Repeat until no more changes (prevents nested tag attacks like <scri<script>pt>)
174
- do {
175
- prev = result;
176
- // 1. Decode HTML entities to prevent bypass (e.g., jav&#x0A;ascript:)
177
- // 2. Remove control characters (NULL, tab, newline, etc.)
178
- // 3. Remove dangerous tags (script, iframe, etc.)
179
- result = _sanitize.decodeEntities(result)
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) + "&gt;";
188
493
  }
189
- } while (result !== prev);
190
- return result;
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, "&lt;");
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-next.2";
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-next.2
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-next.2";
207
+ Plugin.version = "3.18.0";
208
208
  return Plugin;
209
209
  }());
210
210
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "3.18.0-next.2",
3
+ "version": "3.18.0",
4
4
  "description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
5
5
  "homepage": "https://naver.github.io/billboard.js/",
6
6
  "main": "dist/billboard.js",
@@ -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", "idY2Axis", "idGrid"].forEach(v => {
443
+ ["id", "idXAxis", "idYAxis", "idGrid"].forEach(v => {
444
444
  $$.appendClip($el.defs, state.clip[v]);
445
445
  });
446
446
  }