| @@ -96,8 +96,21 @@ | ||
| 96 | 96 | const dataActions = countDownWrap.data("actions"); |
| 97 | 97 | // Skip if in elementor editor |
| 98 | 98 | if ($("body").hasClass("elementor-editor-active")) return; |
| 99 | 99 | |
| 100 | + const normalizeSafeUrl = (rawUrl) => { | |
| 101 | + if (!rawUrl || typeof rawUrl !== "string") return null; | |
| 102 | + try { | |
| 103 | + const url = new URL(rawUrl, window.location.href); | |
| 104 | + if (url.protocol === "http:" || url.protocol === "https:") { | |
| 105 | + return url.href; | |
| 106 | + } | |
| 107 | + } catch (e) { | |
| 108 | + // ignore | |
| 109 | + } | |
| 110 | + return null; | |
| 111 | + }; | |
| 112 | + | |
| 100 | 113 | // Hide the timer |
| 101 | 114 | if (dataActions.hasOwnProperty("hide-timer")) { |
| 102 | 115 | countDownWrap.hide(); |
| 103 | 116 | } |
| @@ -114,17 +127,22 @@ | ||
| 114 | 127 | !$element |
| 115 | 128 | .children(".elementor-widget-container") |
| 116 | 129 | .children(messageSelector).length |
| 117 | 130 | ) { |
| 118 | - countDownWrap.after( | |
| 119 | - `<div class="king-addons-countdown-message">${dataActions["message"]}</div>` | |
| 120 | - ); | |
| 131 | + const $msg = $("<div />", { | |
| 132 | + class: "king-addons-countdown-message", | |
| 133 | + text: String(dataActions["message"] ?? ""), | |
| 134 | + }); | |
| 135 | + countDownWrap.after($msg); | |
| 121 | 136 | } |
| 122 | 137 | } |
| 123 | 138 | |
| 124 | 139 | // Redirect |
| 125 | 140 | if (dataActions.hasOwnProperty("redirect")) { |
| 126 | - window.location.href = dataActions["redirect"]; | |
| 141 | + const destinationUrl = normalizeSafeUrl(dataActions["redirect"]); | |
| 142 | + if (destinationUrl) { | |
| 143 | + window.location.href = destinationUrl; | |
| 144 | + } | |
| 127 | 145 | } |
| 128 | 146 | |
| 129 | 147 | // Load a template (show the next .elementor section) |
| 130 | 148 | if (dataActions.hasOwnProperty("load-template")) { |