diff --git a/e2e/widget.spec.ts b/e2e/widget.spec.ts
index 54826fd..0f2baae 100644
--- a/e2e/widget.spec.ts
+++ b/e2e/widget.spec.ts
@@ -2136,9 +2136,41 @@ test.describe('Custom Icon', () => {
const img = page.locator('#bugdrop-host').locator('css=.bd-trigger-icon img');
await expect(img).toBeVisible();
- // Img src should contain the data URI
+ // Img src should contain the same-origin icon URL
const src = await img.getAttribute('src');
- expect(src).toContain('data:image/png;base64,');
+ expect(src).toContain('/test/bugdrop-icon.svg');
+ });
+
+ test('hostile label and icon config cannot inject markup', async ({ page }) => {
+ await page.goto('/test/index.html');
+ await page.locator('#bugdrop-host').locator('css=.bd-trigger').waitFor();
+
+ await page.evaluate(() => {
+ document.getElementById('bugdrop-host')?.remove();
+
+ const script = document.createElement('script');
+ script.src = '/widget.js';
+ script.dataset.repo = 'mean-weasel/bugdrop-widget-test';
+ script.dataset.label = '';
+ script.dataset.icon = 'javascript:window.__bugdropIconXss = true';
+ document.body.appendChild(script);
+ });
+
+ const host = page.locator('#bugdrop-host');
+ const trigger = host.locator('css=.bd-trigger');
+ await expect(trigger).toBeVisible({ timeout: 5000 });
+
+ await expect(host.locator('css=.bd-trigger-label img')).not.toBeAttached();
+ await expect(host.locator('css=.bd-trigger-icon img')).not.toBeAttached();
+ await expect(host.locator('css=.bd-trigger-label')).toHaveText(
+ '
'
+ );
+
+ const executed = await page.evaluate(() => ({
+ label: Boolean((window as typeof window & { __bugdropLabelXss?: boolean }).__bugdropLabelXss),
+ icon: Boolean((window as typeof window & { __bugdropIconXss?: boolean }).__bugdropIconXss),
+ }));
+ expect(executed).toEqual({ label: false, icon: false });
});
test('broken icon URL falls back to default emoji', async ({ page }) => {
diff --git a/public/test/bugdrop-icon.svg b/public/test/bugdrop-icon.svg
new file mode 100644
index 0000000..9584cff
--- /dev/null
+++ b/public/test/bugdrop-icon.svg
@@ -0,0 +1,4 @@
+
diff --git a/public/test/icon-custom.html b/public/test/icon-custom.html
index 5d8b678..e890e3a 100644
--- a/public/test/icon-custom.html
+++ b/public/test/icon-custom.html
@@ -25,11 +25,11 @@
Test: This page loads BugDrop with data-icon set to a data URI image.
Test: This page loads BugDrop with data-icon set to a same-origin SVG image.
The feedback button should show a custom image instead of the default 🐛 emoji.