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(ris): write the host alone as a source's publisher (#6838)

Lukas8283da4465a6
diff --git a/changelog.d/6837.security.md b/changelog.d/6837.security.md
new file mode 100644
index 0000000000..e0e4a863ee
--- /dev/null
+++ b/changelog.d/6837.security.md
@@ -0,0 +1 @@
+RIS export no longer writes the credentials or port of a source URL into the publisher (`PB`) field: `https://user:[email protected]/…` now exports `PB - arXiv` rather than `PB - user:[email protected]`, and `example.com:8080` exports `PB - example.com`.
diff --git a/src/local_deep_research/text_optimization/citation_formatter.py b/src/local_deep_research/text_optimization/citation_formatter.py
index c4274681a6..b140a5675b 100644
--- a/src/local_deep_research/text_optimization/citation_formatter.py
+++ b/src/local_deep_research/text_optimization/citation_formatter.py
@@ -1645,7 +1645,11 @@ class RISExporter:
from urllib.parse import urlparse
parsed = urlparse(url)
- domain = parsed.netloc
+ # The host alone. The netloc also carries userinfo and port,
+ # so https://user:[email protected]/ wrote the token into the
+ # .ris file as the publisher (#6837). The root dot of a fully
+ # qualified name is dropped, as utilities/arxiv.py does.
+ domain = (parsed.hostname or "").rstrip(".")
if domain.startswith("www."):
domain = domain[4:]
# Extract readable publisher name from domain
diff --git a/tests/text_optimization/test_ris_entry_edge_cases.py b/tests/text_optimization/test_ris_entry_edge_cases.py
index a00b90a558..f08d55e8b2 100644
--- a/tests/text_optimization/test_ris_entry_edge_cases.py
+++ b/tests/text_optimization/test_ris_entry_edge_cases.py
@@ -16,6 +16,7 @@ This file adds coverage for the many remaining branches:
import re
+import pytest
from freezegun import freeze_time
from local_deep_research.text_optimization.citation_formatter import RISExporter
@@ -264,6 +265,23 @@ class TestRISEntryPublisherDetection:
)
assert "PB - arXiv" in result
+ @pytest.mark.parametrize(
+ "url,publisher",
+ [
+ ("https://user:[email protected]/abs/1", "arXiv"),
+ ("https://user:[email protected]/report", "example.com"),
+ ("https://[email protected]/abs/1", "evil.example"),
+ ("https://example.com:8080/article", "example.com"),
+ ("https://ArXiv.org/abs/1", "arXiv"),
+ ("https://arxiv.org./abs/1", "arXiv"),
+ ],
+ )
+ def test_the_publisher_is_the_host_alone(self, url, publisher):
+ """Userinfo and port are not the publisher; credentials in the
+ netloc were written into the .ris file (#6837)."""
+ result = self._make()._create_ris_entry("1", "Title", url=url)
+ assert f"PB - {publisher}\n" in result
+
class TestRISEntryTitleCleaning:
"""Tests for title cleaning patterns."""