~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(exports): strip URL userinfo from LaTeX/BibTeX bibliography links (#7914) (#7974)
Vladimir Babindb8df0a69d72
diff --git a/changelog.d/7914.security.md b/changelog.d/7914.security.mdnew file mode 100644index 0000000000..c0b479ddb5--- /dev/null+++ b/changelog.d/7914.security.md@@ -0,0 +1,7 @@+- LaTeX and BibTeX bibliographies no longer copy credentials from source+ URLs. A link such as `https://user:secret@host/path` was written verbatim+ into `\url{...}` and the generated `.bib`, while the RIS export already+ dropped the `user:secret@` part. Bibliography URLs now go through the RIS+ check as well, so a URL RIS omits is omitted from the bibliography too (the+ LaTeX-breakout check still runs first and may drop more). The report's own+ Sources section is unchanged.diff --git a/src/local_deep_research/text_optimization/citation_formatter.py b/src/local_deep_research/text_optimization/citation_formatter.pyindex 8dfc2ba604..6db89e1dd6 100644--- a/src/local_deep_research/text_optimization/citation_formatter.py+++ b/src/local_deep_research/text_optimization/citation_formatter.py@@ -448,6 +448,11 @@ def _safe_bibtex_url(value: str) -> str:than the one the reader vetted in the report. A URL containing abreakout character is not a URL to repair — it is omitted, and thecaller falls through to its existing URL-less branch.++ What passes that check then goes through ``_safe_ris_url``, so a BibTeX+ or LaTeX bibliography drops URL userinfo (``user:secret@``) exactly as+ the RIS export does, and omits the URLs RIS omits. Before this the+ credential was re-emitted verbatim in ``url = {...}`` and ``\url{...}``."""if any(ch in '{}"\\ ' or is_line_breaking_char(ch) for ch in value):# Local-document sources legitimately trip this: a LangChain@@ -465,7 +470,7 @@ def _safe_bibtex_url(value: str) -> str:"…" if len(value) > 200 else "",)return ""- return value+ return _safe_ris_url(value)def _iter_citation_group(group: str):diff --git a/tests/text_optimization/test_bibliography_escaping.py b/tests/text_optimization/test_bibliography_escaping.pyindex 9940bfb808..d16274fe93 100644--- a/tests/text_optimization/test_bibliography_escaping.py+++ b/tests/text_optimization/test_bibliography_escaping.py@@ -14,8 +14,12 @@ import itertoolsimport pytestfrom local_deep_research.text_optimization.citation_formatter import (+ LaTeXExporter,+ QuartoExporter,+ RISExporter,_escape_bibtex,_safe_bibtex_url,+ _safe_ris_url,is_line_breaking_char,)from local_deep_research.utilities.search_utilities import (@@ -115,6 +119,55 @@ def test_unsafe_urls_are_omitted_not_repaired():)+ "url",+ [+ "https://user:[email protected]/path",+ "https://[email protected]/p?a=1#f",+ "https://user%40x:[email protected]/",+ "ftp://u:[email protected]/x",+ "https:user:[email protected]/",+ "https://h.example/?next=https://u:[email protected]/",+ "https://medium.com/@user/post",+ "https://real.example/p?a=1#frag",+ "/docs/a.pdf",+ ],+)+def test_bibliography_url_matches_ris_on_userinfo(url):+ """LaTeX/BibTeX links drop userinfo exactly as the RIS export does.++ The bibliography used to re-emit ``user:secret@`` while RIS stripped+ it, so a credential in a source URL leaked into one export format+ only (#7914). A URL RIS drops, the bibliography drops too. The converse+ does not hold: the LaTeX-breakout check runs first and is deliberately+ stricter (see ``test_unsafe_urls_are_omitted_not_repaired``). These cases+ all pass that check, which is why the two results are equal here.+ """+ assert _safe_bibtex_url(url) == _safe_ris_url(url)+++def test_exported_bibliographies_carry_no_url_credentials():+ """End to end: the LaTeX ``thebibliography`` block, the generated .bib+ and the RIS export keep the link but not ``user:secret@``.++ Only the bibliography is checked for LaTeX: the report's own Sources+ section is copied into the document body as written, which is a+ separate question from how the bibliography renders its links.+ """+ report = (+ "# Report\n\nA claim [1].\n\n## Sources\n\n"+ "[1] Paper\n URL: https://user:[email protected]/paper\n"+ )+ latex = LaTeXExporter().export_to_latex(report)+ thebibliography = latex[latex.index("\\begin{thebibliography}") :]+ bib = QuartoExporter()._generate_bibliography(report)+ ris = RISExporter().export_to_ris(report)+ for exported in (thebibliography, bib, ris):+ assert "user:secret" not in exported+ assert "host.example/paper" in exported+ assert "\\url{https://host.example/paper}" in thebibliography++def test_both_producers_agree_on_every_bmp_codepoint():"""The Sources renderer and the .bib escaper must not drift.