[PATCH] Fix data loss with localfile field
authorThomas Fischer <thomas.fischer@t-fischer.net>
Mon, 5 Nov 2012 10:50:09 +0000 (11:50 +0100)
committerBastien Roucariès <roucaries.bastien+debian@gmail.com>
Tue, 4 Dec 2012 12:32:20 +0000 (12:32 +0000)
Bibtex file with localfile field are destroyed by current kbibtex.
If you create an article with your favorite editor:

@article{test,
author = "test",
title = "test",
journal = "test",
year = 2012,
localfile = "/tmp/test.pdf",
}

during loading the file kbibtex convert local file to http://test.pdf

The following patch avoid this problem.

bug-debian: http://bugs.debian.org/644024
Forwarded: http://gna.org/bugs/?20275
applied-upstream: 4.1

Gbp-Pq: Name 0005-Fix-data-loss-with-localfile-field.patch

src/libkbibtexio/fileimporterbibtex.cpp

index 570a18681ef4e1e54037d074e823261333de1115..8c83d07657ed78d1f1df98bb4ad25d18f1e69cad 100644 (file)
@@ -534,10 +534,12 @@ FileImporterBibTeX::Token FileImporterBibTeX::readValue(Value& value, const QStr
             if (isStringKey)
                 value.append(new MacroKey(text));
             else {
-                QList<KUrl> urls;
-                FileInfo::urlsInText(text, false, QString::null, urls);
-                for (QList<KUrl>::ConstIterator it = urls.constBegin(); it != urls.constEnd(); ++it)
-                    value.append(new VerbatimText((*it).pathOrUrl()));
+                /// Assumption: in fields like Url or LocalFile, file names are separated by ; or ,
+                static const QRegExp semicolonSpace = QRegExp("[;]\\s*");
+                QStringList fileList = text.split(semicolonSpace, QString::SkipEmptyParts);
+                foreach(const QString &filename, fileList) {
+                    value.append(new VerbatimText(filename));
+                }
             }
         } else if (iKey == Entry::ftMonth) {
             if (isStringKey) {