Bug 115217 - FIle location expansion doesn't escape variable substitutions
Summary: FIle location expansion doesn't escape variable substitutions
Status: RESOLVED FIXED
Alias: None
Product: kaudiocreator
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Gerd Fleischer
URL:
Keywords:
: 128658 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-27 20:41 UTC by flamingice
Modified: 2006-11-06 18:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description flamingice 2005-10-27 20:41:09 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Fedora RPMs
OS:                Linux

If a variable substitution in the Encoded File Location setting (eg. %{albumtitle}) contains ~, the ~ will be expanded to the user's home directory.
Comment 1 Richard Lärkäng 2006-11-06 18:29:23 UTC
SVN commit 602728 by larkang:

Replace '~' by homedir-path before doing the filename expansion
Don't the wav-files when using "Encode File"

BUG: 115217
BUG: 119656


 M  +2 -0      encodefileimp.cpp  
 M  +4 -4      encoder.cpp  
 M  +4 -1      job.h  


--- branches/KDE/3.5/kdemultimedia/kaudiocreator/encodefileimp.cpp #602727:602728
@@ -62,6 +62,8 @@
   newJob->track_artist = track_artist->text();
   newJob->track_comment = track_comment->text();
 
+  newJob->removeTempFile = false;
+
   emit(startJob(newJob));
 
   // Same message and *strings* from tracksimp.cpp
--- branches/KDE/3.5/kdemultimedia/kaudiocreator/encoder.cpp #602727:602728
@@ -159,6 +159,7 @@
 	}
 	
 	QString desiredFile = Prefs::fileFormat();
+	desiredFile.replace( QRegExp("~"), QDir::homeDirPath() );
 	{
 		QMap <QString,QString> map;
 		map.insert("extension", prefs->extension());
@@ -167,7 +168,6 @@
 		jobx.fix("/", "%2f");
 		// If the user wants anything regexp replaced do it now...
 		desiredFile = jobx.replaceSpecialChars(desiredFile, false, map);
-		desiredFile.replace( QRegExp("~"), QDir::homeDirPath() );
 	}
 
 	while ( QFile::exists( desiredFile ) ) {
@@ -284,12 +284,10 @@
 	bool showDebugBox = false;
 	if ( process->exitStatus() == 127 ) {
 		KMessageBox::sorry(0, i18n("The selected encoder was not found.\nThe wav file has been removed. Command was: %1").arg(job->errorString), i18n("Encoding Failed"));
-		QFile::remove(job->location);
 		emit(updateProgress(job->id, -1));
 	}
 	else if ( QFile::exists(job->newLocation) ) {
 		emit(jobIsDone(job, prefs->extension()));
-		QFile::remove(job->location);
 
 		// fyi segfaults return 136
 		if ( process->exitStatus() != 0 ) {
@@ -312,10 +310,12 @@
 		{
 			showDebugBox = true;
 		}
-		QFile::remove( job->location );
 		emit( updateProgress( job->id, -1 ) );
 	}
 
+	if ( job->removeTempFile )
+		QFile::remove( job->location );
+
 	if( showDebugBox ){
 		EncoderOutput dlg( 0, "Encoder Output" );
 		job->output = job->errorString + "\n\n\n" + job->output;
--- branches/KDE/3.5/kdemultimedia/kaudiocreator/job.h #602727:602728
@@ -31,7 +31,7 @@
 class Job{
 
 public:
-	inline Job():id(-1),track_title(""),track_artist(""), track(-1),track_comment(""), year(-1), genre(i18n("Other")), group(""), album(""), comment(""), lastSongInAlbum(false), encoder(-1) {};
+	inline Job():id(-1),track_title(""),track_artist(""), track(-1),track_comment(""), year(-1), genre(i18n("Other")), group(""), album(""), comment(""), lastSongInAlbum(false), removeTempFile(true), encoder(-1) {};
 
 	QString replaceSpecialChars(const QString &string, bool quote, QMap<QString,QString> map);
 
@@ -65,6 +65,9 @@
 	// If this is the last track to be ripped then value is true. 
 	bool lastSongInAlbum;
 
+	// If the file should be removed when finished encoding
+	bool removeTempFile;
+
 	// output from the processing.
 	QString output;
 
Comment 2 Richard Lärkäng 2006-11-06 18:55:55 UTC
*** Bug 128658 has been marked as a duplicate of this bug. ***