Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(web): constrain warning action links to app origin (#7057)

LearningCircuit3311c726dc36
diff --git a/changelog.d/+warning-action-origin.bugfix.md b/changelog.d/+warning-action-origin.bugfix.md
new file mode 100644
index 0000000000..eb64cedc39
--- /dev/null
+++ b/changelog.d/+warning-action-origin.bugfix.md
@@ -0,0 +1 @@
+Warning action links now stay on the application origin after browser URL normalization, including paths with backslashes or control characters.
diff --git a/src/local_deep_research/web/static/js/research_form.js b/src/local_deep_research/web/static/js/research_form.js
index f7a95fa113..84761df359 100644
--- a/src/local_deep_research/web/static/js/research_form.js
+++ b/src/local_deep_research/web/static/js/research_form.js
@@ -295,12 +295,20 @@ function displayWarnings(warnings) {
const isInfo = warning.type === 'searxng_recommendation' || warning.type === 'legacy_server_config' || warning.type === 'backup_info';
const alertClass = isInfo ? 'ldr-alert-info' : 'ldr-alert-warning';
- // Only render an action link for safe internal paths (start with "/" but not "//")
- const safeActionUrl = (typeof warning.actionUrl === 'string'
+ // The browser treats /\host and /<TAB>/host as protocol-relative
+ // URLs too. Resolve the path before deciding whether it stays here.
+ let safeActionUrl = null;
+ if (typeof warning.actionUrl === 'string'
&& warning.actionUrl.startsWith('/')
- && !warning.actionUrl.startsWith('//'))
- ? warning.actionUrl
- : null;
+ && !warning.actionUrl.startsWith('//')) {
+ try {
+ if (new URL(warning.actionUrl, window.location.href).origin === window.location.origin) {
+ safeActionUrl = warning.actionUrl;
+ }
+ } catch (_error) {
+ // A malformed optional action has no link.
+ }
+ }
const actionHtml = safeActionUrl
? `<a href="${esc(safeActionUrl)}" class="ldr-alert-action">
${esc(warning.actionLabel || 'View details')}
diff --git a/tests/js/research-form-warning-coverage.test.js b/tests/js/research-form-warning-coverage.test.js
index 93a12fdfeb..1e510c5ee3 100644
--- a/tests/js/research-form-warning-coverage.test.js
+++ b/tests/js/research-form-warning-coverage.test.js
@@ -85,6 +85,28 @@ it('renders only safe warning actions, escapes fields, and clears the surface',
expect(alert.childElementCount).toBe(0);
});
+it.each([
+ '/\\outside.example/leave',
+ '/\t/outside.example/leave',
+ '/\n/outside.example/leave',
+ '/\r/outside.example/leave',
+])('omits warning actions that the browser resolves off-origin: %j', async actionUrl => {
+ await loadWarningRuntime();
+ expect(new URL(actionUrl, window.location.href).origin)
+ .not.toBe(window.location.origin);
+
+ window.displayWarnings([{
+ type: 'configuration',
+ icon: '!',
+ title: 'Review settings',
+ message: 'Open the settings page',
+ actionUrl,
+ actionLabel: 'Review',
+ }]);
+
+ expect(document.querySelector('.ldr-alert-action')).toBeNull();
+});
+
it('dismisses through the migrated settings contract and refreshes warnings', async () => {
window.api = { getCsrfToken: vi.fn(() => 'csrf-warning-3299') };
const fetchMock = vi.fn((url, options = {}) => {