From ea55ca5e84f0a4b7f8143ef21336fecbabb76300 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 9 Sep 2023 12:57:51 +0200 Subject: [PATCH] Handle bibtex location field syntax file1;file2 This is used, for instance, by zotero with the "betterbibtex" exporter See #12896 --- src/BiblioInfo.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index c5094b285f..63eb2f2263 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -686,16 +686,22 @@ void BibTeXInfo::getLocators(docstring & doi, docstring & url, docstring & file) // get "file" entry from citation record file = operator[]("file"); - // Jabref case, field has a format: + // Jabref case, "file" field has a format (depending on exporter): // Description:Location:Filetype;Description:Location:Filetype... + // or simply: + // Location;Location;... // We will strip out the locations and return an \n-separated list if (!file.empty()) { docstring filelist; vector files = getVectorFromString(file, from_ascii(";")); for (auto const & f : files) { + // first try if we have Description:Location:Filetype docstring ret, filedest, tmp; ret = split(f, tmp, ':'); tmp = split(ret, filedest, ':'); + if (filedest.empty()) + // we haven't, so use the whole string + filedest = f; // TODO howto deal with relative directories? FileName fn(to_utf8(filedest)); if (fn.exists()) { @@ -708,7 +714,7 @@ void BibTeXInfo::getLocators(docstring & doi, docstring & url, docstring & file) file = filelist; } - // kbibtex case, format: + // kbibtex case, "localfile" field with format: // file1.pdf;file2.pdf // We will strip out the locations and return an \n-separated list docstring kfile; -- 2.39.5