[linux-minidisc] Bug: Invalid characters in title strings


Hi,
as reported by a user of the minidiscforum, tracks containing "/" character in the title string will fail to upload. "/" will be treated as a directory separator, so f.open() will fail because of a "missing directory".

I fixed this by removing characters of directory separator type from the title string when creating the filename for output.

This patch can be applied anytime but part #3 of the "netmd download support" patch has to be rebased when applying after this patch. I prefer applying this patch after all parts of the "netmd download support" patch have been committed.

Thomas

>From 6d26bef632420348a9a9917dc9373ad6813cfb28 Mon Sep 17 00:00:00 2001
From: Thomas Arp <manner.moe@gmx.de>
Date: Wed, 15 Jan 2014 19:28:32 +0100
Subject: [PATCH 4/4] remove characters of directory separator type from title
 string when creating filenames for writing

---
 qhimdtransfer/qmddevice.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/qhimdtransfer/qmddevice.cpp b/qhimdtransfer/qmddevice.cpp
index 0be30d6..a23616c 100644
--- a/qhimdtransfer/qmddevice.cpp
+++ b/qhimdtransfer/qmddevice.cpp
@@ -2,6 +2,7 @@
 #include <QMessageBox>
 #include <QApplication>
 #include <QFile>
+#include <QDir>
 #include <tlist.h>
 #include <fileref.h>
 #include <tfile.h>
@@ -104,6 +105,9 @@ void QMDDevice::checkfile(QString UploadDirectory, QString &filename, QString ex
     QString newname;
     int i = 2;
 
+    /* remove chars of directory separator type from filename*/
+    filename.replace(QDir::separator(), " ");
+
     f.setFileName(UploadDirectory + "/" + filename + extension);
     while(f.exists())
     {
-- 
1.8.3.2