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
  */
10
10
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
11
11
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
@@ -384,6 +384,7 @@ var legend$2 = {
384
384
  * @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
385
385
  * - **NOTE:** Should be used along with `legend.contents.template`.
386
386
  * @property {string|function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
387
+ * - **NOTE:** Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.
387
388
  * - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
388
389
  * - {=COLOR}: data color value
389
390
  * - {=TITLE}: data title value
@@ -1060,6 +1061,7 @@ var tooltip$2 = {
1060
1061
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
1061
1062
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
1062
1063
  * - **Note:**
1064
+ * - Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.<br><br>
1063
1065
  * - defaultTitleFormat:
1064
1066
  * - if `axis.x.tick.format` option will be used if set.
1065
1067
  * - otherwise, will return function based on tick format type(category, timeseries).
@@ -1069,7 +1071,8 @@ var tooltip$2 = {
1069
1071
  * - otherwise, will parse value and return as number.
1070
1072
  * @property {string|HTMLElement} [tooltip.contents.bindto=undefined] Set CSS selector or element reference to bind tooltip.
1071
1073
  * - **NOTE:** When is specified, will not be updating tooltip's position.
1072
- * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.<br><br>
1074
+ * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.
1075
+ * - **NOTE:** Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.<br><br>
1073
1076
  * Within template, below syntax will be replaced using template-like syntax string:
1074
1077
  * - **{{ ... }}**: the doubly curly brackets indicate loop block for data rows.
1075
1078
  * - **{=CLASS_TOOLTIP}**: default tooltip class name `bb-tooltip`.
@@ -2324,6 +2327,431 @@ var win = getGlobal();
2324
2327
  var doc = win === null || win === void 0 ? void 0 : win.document;
2325
2328
  var _a = getFallback(win), requestAnimationFrame = _a[0], requestIdleCallback = _a[2];
2326
2329
 
2330
+ /**
2331
+ * Copyright (c) 2017 ~ present NAVER Corp.
2332
+ * billboard.js project is licensed under the MIT license
2333
+ * @ignore
2334
+ */
2335
+ /**
2336
+ * HTML/SVG Sanitization module
2337
+ * Pure whitelist approach - only explicitly allowed tags, attributes, and protocols pass through
2338
+ */
2339
+ // Whitelist of allowed HTML/SVG tags
2340
+ var ALLOWED_TAGS = new Set([
2341
+ // HTML tags for tooltip/legend templates
2342
+ "span",
2343
+ "div",
2344
+ "p",
2345
+ "br",
2346
+ "b",
2347
+ "i",
2348
+ "em",
2349
+ "strong",
2350
+ "u",
2351
+ "s",
2352
+ "sub",
2353
+ "sup",
2354
+ "ul",
2355
+ "ol",
2356
+ "li",
2357
+ "dl",
2358
+ "dt",
2359
+ "dd",
2360
+ "table",
2361
+ "thead",
2362
+ "tbody",
2363
+ "tfoot",
2364
+ "tr",
2365
+ "th",
2366
+ "td",
2367
+ "caption",
2368
+ "colgroup",
2369
+ "col",
2370
+ "hr",
2371
+ "pre",
2372
+ "code",
2373
+ "blockquote",
2374
+ "a",
2375
+ "img",
2376
+ // SVG tags for point patterns
2377
+ "svg",
2378
+ "g",
2379
+ "path",
2380
+ "circle",
2381
+ "ellipse",
2382
+ "rect",
2383
+ "line",
2384
+ "polyline",
2385
+ "polygon",
2386
+ "text",
2387
+ "tspan",
2388
+ "textPath",
2389
+ "use",
2390
+ "defs",
2391
+ "symbol",
2392
+ "clipPath",
2393
+ "mask",
2394
+ "linearGradient",
2395
+ "radialGradient",
2396
+ "stop",
2397
+ "pattern",
2398
+ "marker",
2399
+ "title",
2400
+ "desc"
2401
+ ]);
2402
+ // Whitelist of allowed attributes
2403
+ var ALLOWED_ATTRS = new Set([
2404
+ // Common attributes
2405
+ "class",
2406
+ "id",
2407
+ "style",
2408
+ "title",
2409
+ "lang",
2410
+ "dir",
2411
+ // HTML specific
2412
+ "href",
2413
+ "src",
2414
+ "alt",
2415
+ "width",
2416
+ "height",
2417
+ "colspan",
2418
+ "rowspan",
2419
+ "scope",
2420
+ "headers",
2421
+ // SVG presentation attributes
2422
+ "d",
2423
+ "points",
2424
+ "x",
2425
+ "y",
2426
+ "x1",
2427
+ "x2",
2428
+ "y1",
2429
+ "y2",
2430
+ "cx",
2431
+ "cy",
2432
+ "r",
2433
+ "rx",
2434
+ "ry",
2435
+ "dx",
2436
+ "dy",
2437
+ "viewBox",
2438
+ "preserveAspectRatio",
2439
+ "transform",
2440
+ "fill",
2441
+ "fill-opacity",
2442
+ "fill-rule",
2443
+ "stroke",
2444
+ "stroke-width",
2445
+ "stroke-opacity",
2446
+ "stroke-linecap",
2447
+ "stroke-linejoin",
2448
+ "stroke-dasharray",
2449
+ "stroke-dashoffset",
2450
+ "opacity",
2451
+ "clip-path",
2452
+ "clip-rule",
2453
+ "mask",
2454
+ "font-family",
2455
+ "font-size",
2456
+ "font-weight",
2457
+ "font-style",
2458
+ "text-anchor",
2459
+ "dominant-baseline",
2460
+ "offset",
2461
+ "stop-color",
2462
+ "stop-opacity",
2463
+ "gradientUnits",
2464
+ "gradientTransform",
2465
+ "spreadMethod",
2466
+ "patternUnits",
2467
+ "patternTransform",
2468
+ "marker-start",
2469
+ "marker-mid",
2470
+ "marker-end",
2471
+ "markerWidth",
2472
+ "markerHeight",
2473
+ "refX",
2474
+ "refY",
2475
+ "xlink:href"
2476
+ ]);
2477
+ // Whitelist of allowed URI protocols
2478
+ var ALLOWED_URI_PROTOCOLS = new Set([
2479
+ "http:",
2480
+ "https:",
2481
+ "mailto:"
2482
+ ]);
2483
+ // Attributes that contain URIs
2484
+ var URI_ATTRS = new Set(["href", "src", "xlink:href"]);
2485
+ // Pre-compiled regex patterns for performance
2486
+ var TAG_NAME_REGEX = /^<\/?([a-zA-Z][a-zA-Z0-9]*)/;
2487
+ var CLOSING_TAG_REGEX = /^<\/([a-zA-Z][a-zA-Z0-9]*)\s*>$/;
2488
+ var OPENING_TAG_REGEX = /^<([a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?)>$/;
2489
+ var ATTR_REGEX = /([a-zA-Z][\w:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
2490
+ var URL_IN_STYLE_REGEX = /url\s*\(\s*["']?([^"')]+)["']?\s*\)/gi;
2491
+ // Dangerous CSS patterns
2492
+ var DANGEROUS_CSS_PATTERNS = [
2493
+ "expression(",
2494
+ "behavior:",
2495
+ "binding:",
2496
+ "@import",
2497
+ "@charset",
2498
+ "-moz-binding:"
2499
+ ];
2500
+ /**
2501
+ * Decode HTML entities in a string
2502
+ * @param {string} str String with potential HTML entities
2503
+ * @returns {string} Decoded string
2504
+ * @private
2505
+ */
2506
+ function decodeHTMLEntities(str) {
2507
+ return str
2508
+ // Named entities
2509
+ .replace(/&colon;/gi, ":")
2510
+ .replace(/&newline;/gi, "\n")
2511
+ .replace(/&tab;/gi, "\t")
2512
+ .replace(/&nbsp;/gi, " ")
2513
+ .replace(/&lt;/gi, "<")
2514
+ .replace(/&gt;/gi, ">")
2515
+ .replace(/&amp;/gi, "&")
2516
+ .replace(/&quot;/gi, "\"")
2517
+ .replace(/&apos;/gi, "'")
2518
+ // Numeric entities (decimal)
2519
+ .replace(/&#(\d+);/gi, function (_, code) { return String.fromCharCode(parseInt(code, 10)); })
2520
+ // Numeric entities (hex)
2521
+ .replace(/&#x([0-9a-f]+);/gi, function (_, code) { return String.fromCharCode(parseInt(code, 16)); });
2522
+ }
2523
+ /**
2524
+ * Check if a URI is safe (whitelist approach)
2525
+ * @param {string} uri URI to check
2526
+ * @returns {boolean} Whether the URI is safe
2527
+ * @private
2528
+ */
2529
+ function isSafeURI(uri) {
2530
+ // Decode HTML entities first to prevent bypass
2531
+ var decoded = decodeHTMLEntities(uri).trim();
2532
+ // Remove any whitespace/control characters that could be used for bypass
2533
+ // eslint-disable-next-line no-control-regex
2534
+ var normalized = decoded.replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
2535
+ // Empty or fragment-only URIs are safe
2536
+ if (!normalized || normalized.startsWith("#")) {
2537
+ return true;
2538
+ }
2539
+ // Relative paths are safe
2540
+ if (normalized.startsWith("/") ||
2541
+ normalized.startsWith("./") ||
2542
+ normalized.startsWith("../") ||
2543
+ !normalized.includes(":")) {
2544
+ return true;
2545
+ }
2546
+ // Check if protocol is in whitelist
2547
+ var colonIndex = normalized.indexOf(":");
2548
+ if (colonIndex > 0) {
2549
+ var protocol = normalized.substring(0, colonIndex + 1);
2550
+ return ALLOWED_URI_PROTOCOLS.has(protocol);
2551
+ }
2552
+ return false;
2553
+ }
2554
+ /**
2555
+ * Check if a style value is safe (whitelist approach)
2556
+ * @param {string} style Style attribute value
2557
+ * @returns {string|null} Sanitized style or null if unsafe
2558
+ * @private
2559
+ */
2560
+ function sanitizeStyleValue(style) {
2561
+ // Decode HTML entities first
2562
+ var decoded = decodeHTMLEntities(style);
2563
+ // Remove any control characters
2564
+ // eslint-disable-next-line no-control-regex
2565
+ var cleaned = decoded.replace(/[\u0000-\u001f]/g, "");
2566
+ // Check for url() - only allow safe URIs inside
2567
+ URL_IN_STYLE_REGEX.lastIndex = 0;
2568
+ var match;
2569
+ while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) {
2570
+ if (!isSafeURI(match[1])) {
2571
+ return null;
2572
+ }
2573
+ }
2574
+ // Check for dangerous CSS patterns (expression, behavior, etc.)
2575
+ var normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
2576
+ for (var _i = 0, DANGEROUS_CSS_PATTERNS_1 = DANGEROUS_CSS_PATTERNS; _i < DANGEROUS_CSS_PATTERNS_1.length; _i++) {
2577
+ var pattern = DANGEROUS_CSS_PATTERNS_1[_i];
2578
+ if (normalizedLower.includes(pattern)) {
2579
+ return null;
2580
+ }
2581
+ }
2582
+ return style;
2583
+ }
2584
+ // Lookup table for encoding dangerous characters in attribute values
2585
+ var ATTR_ENCODE_MAP = {
2586
+ "\"": "&quot;",
2587
+ "'": "&#39;",
2588
+ "`": "&#96;"
2589
+ };
2590
+ var ATTR_ENCODE_REGEX = /["'`]/g;
2591
+ /**
2592
+ * Encode dangerous characters in attribute values to HTML entities
2593
+ * This prevents attribute injection attacks where quotes/backticks break out of the attribute context
2594
+ * @param {string} value Attribute value
2595
+ * @returns {string} Encoded value
2596
+ * @private
2597
+ */
2598
+ function encodeAttrValue(value) {
2599
+ return value.replace(ATTR_ENCODE_REGEX, function (char) { return ATTR_ENCODE_MAP[char]; });
2600
+ }
2601
+ /**
2602
+ * Sanitize attribute value using whitelist approach
2603
+ * @param {string} name Attribute name
2604
+ * @param {string} value Attribute value
2605
+ * @param {boolean} wasUnquoted Whether the value was originally unquoted
2606
+ * @returns {string|null} Sanitized value if safe, null if should be removed
2607
+ * @private
2608
+ */
2609
+ function sanitizeAttrValue(name, value, wasUnquoted) {
2610
+ if (wasUnquoted === void 0) { wasUnquoted = false; }
2611
+ // Check URI attributes with whitelist
2612
+ if (URI_ATTRS.has(name)) {
2613
+ if (!isSafeURI(value)) {
2614
+ return null;
2615
+ }
2616
+ // Encode dangerous characters in URI values to prevent attribute injection
2617
+ return wasUnquoted ? encodeAttrValue(value) : value;
2618
+ }
2619
+ // Check style attribute
2620
+ if (name === "style") {
2621
+ var sanitizedStyle = sanitizeStyleValue(value);
2622
+ if (sanitizedStyle === null) {
2623
+ return null;
2624
+ }
2625
+ // Encode dangerous characters in style values
2626
+ return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
2627
+ }
2628
+ // For other attributes, check for embedded event handlers
2629
+ var decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
2630
+ if (/\bon\w+=/.test(decoded)) {
2631
+ return null;
2632
+ }
2633
+ // Encode dangerous characters to prevent attribute injection
2634
+ return wasUnquoted ? encodeAttrValue(value) : value;
2635
+ }
2636
+ /**
2637
+ * Extract tag name from a tag string
2638
+ * Returns null if not a valid tag format
2639
+ * @param {string} tag Tag string starting with <
2640
+ * @returns {string|null} Lowercase tag name or null
2641
+ * @private
2642
+ */
2643
+ function extractTagName(tag) {
2644
+ // Must start with < followed immediately by letter (no spaces allowed)
2645
+ var match = tag.match(TAG_NAME_REGEX);
2646
+ return match ? match[1].toLowerCase() : null;
2647
+ }
2648
+ /**
2649
+ * Check if a tag is in the whitelist
2650
+ * @param {string} tag Tag string
2651
+ * @returns {boolean} Whether tag is allowed
2652
+ * @private
2653
+ */
2654
+ function isAllowedTag(tag) {
2655
+ var tagName = extractTagName(tag);
2656
+ return tagName !== null && ALLOWED_TAGS.has(tagName);
2657
+ }
2658
+ /**
2659
+ * Sanitize a single HTML/SVG tag (only called for allowed tags)
2660
+ * @param {string} fullTag The full tag string including < and >
2661
+ * @returns {string} Sanitized tag
2662
+ * @private
2663
+ */
2664
+ function sanitizeTag(fullTag) {
2665
+ // Closing tag
2666
+ var closingMatch = fullTag.match(CLOSING_TAG_REGEX);
2667
+ if (closingMatch) {
2668
+ return "</".concat(closingMatch[1].toLowerCase(), ">");
2669
+ }
2670
+ // Opening tag
2671
+ var openingMatch = fullTag.match(OPENING_TAG_REGEX);
2672
+ if (!openingMatch) {
2673
+ return "";
2674
+ }
2675
+ var tagName = openingMatch[1], attrString = openingMatch[2], selfClose = openingMatch[3];
2676
+ var lowerTagName = tagName.toLowerCase();
2677
+ // Parse and filter attributes, preserving original quote style
2678
+ var allowedAttrs = [];
2679
+ ATTR_REGEX.lastIndex = 0;
2680
+ var attrMatch;
2681
+ while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
2682
+ var attrName = attrMatch[1].toLowerCase();
2683
+ var doubleQuotedValue = attrMatch[2];
2684
+ var singleQuotedValue = attrMatch[3];
2685
+ var unquotedValue = attrMatch[4];
2686
+ // Skip event handlers (on*)
2687
+ if (attrName.startsWith("on")) {
2688
+ continue;
2689
+ }
2690
+ // Determine original quote style and value
2691
+ var attrValue = void 0;
2692
+ var quoteChar = void 0;
2693
+ if (doubleQuotedValue !== undefined) {
2694
+ attrValue = doubleQuotedValue;
2695
+ quoteChar = "\"";
2696
+ }
2697
+ else if (singleQuotedValue !== undefined) {
2698
+ attrValue = singleQuotedValue;
2699
+ quoteChar = "'";
2700
+ }
2701
+ else if (unquotedValue !== undefined) {
2702
+ attrValue = unquotedValue;
2703
+ quoteChar = "\"";
2704
+ }
2705
+ else {
2706
+ // Boolean attribute (no value)
2707
+ if (ALLOWED_ATTRS.has(attrName)) {
2708
+ allowedAttrs.push(attrName);
2709
+ }
2710
+ continue;
2711
+ }
2712
+ if (ALLOWED_ATTRS.has(attrName)) {
2713
+ var wasUnquoted = unquotedValue !== undefined;
2714
+ var sanitizedValue = sanitizeAttrValue(attrName, attrValue, wasUnquoted);
2715
+ if (sanitizedValue !== null) {
2716
+ allowedAttrs.push("".concat(attrName, "=").concat(quoteChar).concat(sanitizedValue).concat(quoteChar));
2717
+ }
2718
+ }
2719
+ }
2720
+ var attrsStr = allowedAttrs.length > 0 ? " ".concat(allowedAttrs.join(" ")) : "";
2721
+ var selfCloseStr = selfClose ? "/>" : ">";
2722
+ return "<".concat(lowerTagName).concat(attrsStr).concat(selfCloseStr);
2723
+ }
2724
+ /**
2725
+ * Sanitize HTML string to prevent XSS attacks
2726
+ * Pure whitelist approach - allowed tags are sanitized, others are escaped
2727
+ * @param {string} str Target string value
2728
+ * @returns {string} Sanitized string with only allowed elements
2729
+ * @private
2730
+ */
2731
+ function sanitize(str) {
2732
+ if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
2733
+ return str;
2734
+ }
2735
+ // Single pass: sanitize allowed tags, escape disallowed ones
2736
+ // Also match orphaned fragments like "ipt>" from broken tags
2737
+ return str.replace(/<\/?[^>]*>|[^<>\s]+>/g, function (match) {
2738
+ // Remove HTML comments
2739
+ if (match.startsWith("<!--")) {
2740
+ return "";
2741
+ }
2742
+ // Orphaned fragment (e.g., "ipt>") → escape '>'
2743
+ if (!match.startsWith("<")) {
2744
+ return match.slice(0, -1) + "&gt;";
2745
+ }
2746
+ // Allowed tag → sanitize attributes
2747
+ if (isAllowedTag(match)) {
2748
+ return sanitizeTag(match);
2749
+ }
2750
+ // Disallowed tag → escape all '<' to prevent execution
2751
+ return match.replace(/</g, "&lt;");
2752
+ });
2753
+ }
2754
+
2327
2755
  // ====================================
2328
2756
  // Internal Helper (Not Exported)
2329
2757
  // ====================================
@@ -2363,81 +2791,6 @@ function _forEachValidItem(items, callback) {
2363
2791
  }
2364
2792
  }
2365
2793
  }
2366
- /**
2367
- * Private sanitization utilities
2368
- * Encapsulates all XSS prevention patterns and helper functions
2369
- * @private
2370
- */
2371
- var _sanitize = (function () {
2372
- var DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
2373
- // HTML entity character code map (for decoding)
2374
- var ENTITY_MAP = {
2375
- quot: 34,
2376
- amp: 38,
2377
- apos: 39,
2378
- lt: 60,
2379
- gt: 62,
2380
- nbsp: 160,
2381
- iexcl: 161,
2382
- cent: 162,
2383
- pound: 163,
2384
- curren: 164,
2385
- yen: 165
2386
- };
2387
- // Angle bracket codes (< and >) - never decode these to prevent tag bypass
2388
- var LT_CODE = 60;
2389
- var GT_CODE = 62;
2390
- // Maximum sanitization iterations to prevent infinite loops
2391
- var MAX_ITERATIONS = 10;
2392
- // Regular expressions (compiled once for performance)
2393
- var rx = {
2394
- tags: new RegExp("<(".concat(DANGEROUS_TAGS, ")\\b[\\s\\S]*?>([\\s\\S]*?<\\/(").concat(DANGEROUS_TAGS, ")\\s*>)?"), "gi"),
2395
- htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
2396
- // eslint-disable-next-line no-control-regex
2397
- controlChar: /[\x00-\x1F\x7F]/g,
2398
- eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
2399
- dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
2400
- dangerousProtocol: /^(javascript|data|vbscript):/
2401
- };
2402
- return {
2403
- ENTITY_MAP: ENTITY_MAP,
2404
- LT_CODE: LT_CODE,
2405
- GT_CODE: GT_CODE,
2406
- MAX_ITERATIONS: MAX_ITERATIONS,
2407
- rx: rx,
2408
- /**
2409
- * Decode HTML entities to prevent bypass attacks
2410
- * @param {string} str String with potential HTML entities
2411
- * @returns {string} Decoded string
2412
- */
2413
- decodeEntities: function (str) {
2414
- return str.replace(rx.htmlEntity, function (match, hex, dec, named) {
2415
- var code = hex ?
2416
- parseInt(hex, 16) :
2417
- dec ?
2418
- parseInt(dec, 10) :
2419
- named ?
2420
- ENTITY_MAP[named.toLowerCase()] || 0 :
2421
- 0;
2422
- // Never decode angle brackets to prevent tag bypass
2423
- return code && code !== LT_CODE && code !== GT_CODE ?
2424
- String.fromCharCode(code) :
2425
- match;
2426
- });
2427
- },
2428
- /**
2429
- * Remove dangerous URI protocols from attribute values
2430
- * @param {string} str String to sanitize
2431
- * @returns {string} Sanitized string
2432
- */
2433
- removeDangerousUris: function (str) {
2434
- return str.replace(rx.dangerousUri, function (match, attr, quote, value) {
2435
- var normalized = value.toLowerCase().replace(/\s/g, "");
2436
- return rx.dangerousProtocol.test(normalized) ? "".concat(attr, "=").concat(quote).concat(quote) : match;
2437
- });
2438
- }
2439
- };
2440
- })();
2441
2794
  // ====================================
2442
2795
  // Exported
2443
2796
  // ====================================
@@ -2544,41 +2897,6 @@ function endall(transition, cb) {
2544
2897
  transition.call(end);
2545
2898
  }
2546
2899
  }
2547
- /**
2548
- * Sanitize HTML string to prevent XSS attacks
2549
- * Uses blacklist approach with repeated application to prevent nested tag bypass
2550
- * Handles encoded characters (HTML entities, Unicode escapes) to prevent bypass attacks
2551
- * @param {string} str Target string value
2552
- * @returns {string} Sanitized string with dangerous elements removed
2553
- * @private
2554
- */
2555
- function sanitize(str) {
2556
- // Early return for non-string, empty string, or string without HTML
2557
- if (!isString(str) || !str || str.indexOf("<") === -1) {
2558
- return str;
2559
- }
2560
- var result = str;
2561
- var prev;
2562
- var iterations = 0;
2563
- // Repeat until no more changes (prevents nested tag attacks like <scri<script>pt>)
2564
- do {
2565
- prev = result;
2566
- // 1. Decode HTML entities to prevent bypass (e.g., jav&#x0A;ascript:)
2567
- // 2. Remove control characters (NULL, tab, newline, etc.)
2568
- // 3. Remove dangerous tags (script, iframe, etc.)
2569
- result = _sanitize.decodeEntities(result)
2570
- .replace(_sanitize.rx.controlChar, "")
2571
- .replace(_sanitize.rx.tags, "")
2572
- .replace(_sanitize.rx.eventHandler, ""); // 4. Remove event handlers
2573
- // 5. Remove dangerous URIs (javascript:, data:, vbscript:)
2574
- result = _sanitize.removeDangerousUris(result);
2575
- // Safety check to prevent infinite loops
2576
- if (++iterations >= _sanitize.MAX_ITERATIONS) {
2577
- break;
2578
- }
2579
- } while (result !== prev);
2580
- return result;
2581
- }
2582
2900
  /**
2583
2901
  * Set text value. If there're multiline add nodes.
2584
2902
  * @param {d3Selection} node Text node
@@ -9249,7 +9567,7 @@ var tooltip$1 = {
9249
9567
  }
9250
9568
  var $$ = this;
9251
9569
  var api = $$.api, config = $$.config;
9252
- return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, args) : $$.getTooltipContent.apply($$, args);
9570
+ return sanitize(isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api).apply(void 0, args) : $$.getTooltipContent.apply($$, args));
9253
9571
  },
9254
9572
  /**
9255
9573
  * Returns the tooltip content(HTML string)
@@ -9269,20 +9587,20 @@ var tooltip$1 = {
9269
9587
  var fn = config["tooltip_format_".concat(v)];
9270
9588
  return isFunction(fn) ? fn.bind(api) : fn;
9271
9589
  }), titleFn = _b[0], nameFn = _b[1], valueFn = _b[2];
9272
- // determine fotmatter function with sanitization
9590
+ // determine formatter function
9273
9591
  var titleFormat = function () {
9274
9592
  var arg = [];
9275
9593
  for (var _i = 0; _i < arguments.length; _i++) {
9276
9594
  arg[_i] = arguments[_i];
9277
9595
  }
9278
- return sanitize((titleFn || defaultTitleFormat).apply(void 0, arg));
9596
+ return (titleFn || defaultTitleFormat).apply(void 0, arg);
9279
9597
  };
9280
9598
  var nameFormat = function () {
9281
9599
  var arg = [];
9282
9600
  for (var _i = 0; _i < arguments.length; _i++) {
9283
9601
  arg[_i] = arguments[_i];
9284
9602
  }
9285
- return sanitize((nameFn || (function (name) { return name; })).apply(void 0, arg));
9603
+ return (nameFn || (function (name) { return name; })).apply(void 0, arg);
9286
9604
  };
9287
9605
  var valueFormat = function (v, ratio, id, index) {
9288
9606
  var fn = valueFn;
@@ -9297,7 +9615,7 @@ var tooltip$1 = {
9297
9615
  fn = defaultValueFormat;
9298
9616
  }
9299
9617
  }
9300
- return sanitize(fn(v, ratio, id, index));
9618
+ return fn(v, ratio, id, index);
9301
9619
  };
9302
9620
  var order = config.tooltip_order;
9303
9621
  var getRowValue = function (row) { return ($$.axis && $$.isBubbleZType(row) ?
@@ -9613,11 +9931,11 @@ var tooltip$1 = {
9613
9931
  callFn(config.tooltip_onshow, $$.api, selectedData);
9614
9932
  // set tooltip content
9615
9933
  tooltip
9616
- .html(sanitize($$.getTooltipHTML(selectedData, // data
9934
+ .html($$.getTooltipHTML(selectedData, // data
9617
9935
  $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$), // defaultTitleFormat
9618
9936
  $$.getDefaultValueFormat(), // defaultValueFormat
9619
9937
  $$.color // color
9620
- )))
9938
+ ))
9621
9939
  .style("display", null)
9622
9940
  .style("visibility", null) // for IE9
9623
9941
  .datum(datum = {
@@ -10865,7 +11183,7 @@ var ChartInternal = /** @class */ (function () {
10865
11183
  labelsBGColor || ((_a = $$.hasLegendDefsPoint) === null || _a === void 0 ? void 0 : _a.call($$))) {
10866
11184
  $el.defs = $el.svg.append("defs");
10867
11185
  if (hasAxis) {
10868
- ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(function (v) {
11186
+ ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
10869
11187
  $$.appendClip($el.defs, state.clip[v]);
10870
11188
  });
10871
11189
  }
@@ -18021,18 +18339,6 @@ var y = {
18021
18339
  * y2 Axis config options
18022
18340
  */
18023
18341
  var y2 = {
18024
- /**
18025
- * Set clip-path attribute for y2 axis element
18026
- * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
18027
- * @name axis․y2․clipPath
18028
- * @memberof Options
18029
- * @type {boolean}
18030
- * @default true
18031
- * @example
18032
- * // don't set 'clip-path' attribute
18033
- * clipPath: false
18034
- */
18035
- axis_y2_clipPath: true,
18036
18342
  /**
18037
18343
  * Show or hide y2 axis.
18038
18344
  * - **NOTE**:
@@ -23068,7 +23374,7 @@ var optPoint = {
23068
23374
  * - This is an `experimental` feature and can have some unexpected behaviors.
23069
23375
  * - If chart has 'bubble' type, only circle can be used.
23070
23376
  * - For IE, non circle point expansions are not supported due to lack of transform support.
23071
- * - While basic XSS sanitization is applied, if you're allowing user-provided chart options in a service exposed to other users, you should implement additional security measures to prevent sophisticated XSS attacks.
23377
+ * - Only common SVG tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.
23072
23378
  * - **Available Values:**
23073
23379
  * - circle
23074
23380
  * - rectangle
@@ -26547,7 +26853,7 @@ var zoomModule = function () {
26547
26853
  var defaults = Object.create(null);
26548
26854
  /**
26549
26855
  * @namespace bb
26550
- * @version 3.18.0-next.2
26856
+ * @version 3.18.0
26551
26857
  */
26552
26858
  var bb = {
26553
26859
  /**
@@ -26557,7 +26863,7 @@ var bb = {
26557
26863
  * bb.version; // "1.0.0"
26558
26864
  * @memberof bb
26559
26865
  */
26560
- version: "3.18.0-next.2",
26866
+ version: "3.18.0",
26561
26867
  /**
26562
26868
  * Generate chart
26563
26869
  * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when: