[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/plugins/kmail/bodypartformatter
From: Bo Thorsen <bo () sonofthor ! dk>
Date: 2004-08-17 14:11:59
Message-ID: 20040817141159.8B58999A8 () office ! kde ! org
[Download RAW message or body]
CVS commit by thorsen:
Fix use of locateLocal, and avoid a potential tempfile attack on the saved file. And \
make the code more 'KDE-like'
M +9 -18 text_calendar.cpp 1.22
--- kdepim/plugins/kmail/bodypartformatter/text_calendar.cpp #1.21:1.22
@@ -54,8 +54,9 @@
#include <kstandarddirs.h>
#include <kapplication.h>
+#include <ktempfile.h>
#include <qurl.h>
-#include <qfile.h>
#include <qdir.h>
+#include <qtextstream.h>
using namespace KCal;
@@ -534,23 +535,13 @@ class UrlHandler : public KMail::Interfa
const QString& type ) const
{
- QString location = locateLocal( "data", "korganizer/income." + type,
- true );
- QDir dir;
- if ( !dir.exists( location ) ) dir.mkdir( location );
- QString file;
- do {
- file = location + "/" + KApplication::randomString( 10 );
- } while ( QFile::exists( file ) );
- QFile f( file );
- if ( !f.open( IO_WriteOnly ) ) {
- KMessageBox::error( 0, i18n("Could not open file for writing:\n%1")
- .arg( file ) );
+ KTempFile file( locateLocal( "data", "korganizer/income." + type + '/',
+ true ) );
+ QTextStream* ts = file.textStream();
+ if ( !ts ) {
+ KMessageBox::error( 0, i18n("Could not save file to KOrganizer") );
return false;
- } else {
- const QString message = receiver + '\n' + iCal;
- QByteArray msgArray = message.utf8();
- f.writeBlock( msgArray, msgArray.size() );
- f.close();
}
+ ts->setEncoding( QTextStream::UnicodeUTF8 );
+ (*ts) << receiver << '\n' << iCal;
return true;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic