@juspay/svelte-ui-components 4.11.2 → 4.11.3
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/Img/Img.svelte +20 -9
- package/dist-wc/index.js +6 -3
- package/package.json +1 -1
package/dist/Img/Img.svelte
CHANGED
|
@@ -145,16 +145,27 @@
|
|
|
145
145
|
const URL_ATTRIBUTES: ReadonlySet<string> = new Set(['href', 'xlink:href', 'src']);
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* Whether a URL attribute
|
|
148
|
+
* Whether a URL attribute is safe to adopt into the live document.
|
|
149
149
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
150
|
+
* A fragment (`#gradient`) points inside this same document and is safe on
|
|
151
|
+
* any element. A `data:image/*` payload also carries its art inline and makes
|
|
152
|
+
* no network request on adoption — but it is only safe on image-rendering
|
|
153
|
+
* elements (`<image>`, `<feImage>`), where the payload is rasterized with no
|
|
154
|
+
* script context. On any other element (`<use>`, `<a>`, …) the allowance
|
|
155
|
+
* stays fragment-only. Media type comparison is case-insensitive because
|
|
156
|
+
* MIME types are. Everything else is unsafe: a `javascript:` URL is the
|
|
157
|
+
* classic vector, and an ordinary remote URL fetches on adoption, which is
|
|
158
|
+
* a request the consumer's page never asked to make, from markup the
|
|
159
|
+
* consumer did not write.
|
|
155
160
|
*/
|
|
156
|
-
function
|
|
157
|
-
|
|
161
|
+
function isSafeInlineUrlValue(element: Element, value: string): boolean {
|
|
162
|
+
const trimmed = value.trim();
|
|
163
|
+
if (trimmed.startsWith('#')) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
const localName = element.localName.toLowerCase();
|
|
167
|
+
const isImageSink = localName === 'image' || localName === 'feimage';
|
|
168
|
+
return isImageSink && trimmed.toLowerCase().startsWith('data:image/');
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
/**
|
|
@@ -185,7 +196,7 @@
|
|
|
185
196
|
element.removeAttribute(attribute.name);
|
|
186
197
|
continue;
|
|
187
198
|
}
|
|
188
|
-
if (URL_ATTRIBUTES.has(name) && !
|
|
199
|
+
if (URL_ATTRIBUTES.has(name) && !isSafeInlineUrlValue(element, attribute.value)) {
|
|
189
200
|
element.removeAttribute(attribute.name);
|
|
190
201
|
}
|
|
191
202
|
}
|
package/dist-wc/index.js
CHANGED
|
@@ -3581,8 +3581,11 @@ function Img(e, t) {
|
|
|
3581
3581
|
"xlink:href",
|
|
3582
3582
|
"src"
|
|
3583
3583
|
]);
|
|
3584
|
-
function Me(e) {
|
|
3585
|
-
|
|
3584
|
+
function Me(e, t) {
|
|
3585
|
+
let n = t.trim();
|
|
3586
|
+
if (n.startsWith("#")) return !0;
|
|
3587
|
+
let i = e.localName.toLowerCase();
|
|
3588
|
+
return (i === "image" || i === "feimage") && n.toLowerCase().startsWith("data:image/");
|
|
3586
3589
|
}
|
|
3587
3590
|
function Re(e) {
|
|
3588
3591
|
for (let t of Array.from(e.querySelectorAll("script, foreignObject, animate, animateMotion, animateTransform, set, mpath, discard"))) t.remove();
|
|
@@ -3592,7 +3595,7 @@ function Img(e, t) {
|
|
|
3592
3595
|
t.removeAttribute(e.name);
|
|
3593
3596
|
continue;
|
|
3594
3597
|
}
|
|
3595
|
-
be.has(n) && !Me(e.value) && t.removeAttribute(e.name);
|
|
3598
|
+
be.has(n) && !Me(t, e.value) && t.removeAttribute(e.name);
|
|
3596
3599
|
}
|
|
3597
3600
|
}
|
|
3598
3601
|
function Ue(e) {
|