summaryrefslogtreecommitdiff
path: root/library/config.cpp
Side-by-side diff
Diffstat (limited to 'library/config.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/config.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/library/config.cpp b/library/config.cpp
index b47c620..b28c771 100644
--- a/library/config.cpp
+++ b/library/config.cpp
@@ -500,48 +500,58 @@ void Config::write( const QString &fn )
*/
bool Config::isValid() const
{
return groups.end() != git;
}
/*!
\internal
*/
void Config::read()
{
changed = FALSE;
if ( !QFileInfo( filename ).exists() ) {
git = groups.end();
return;
}
QFile f( filename );
if ( !f.open( IO_ReadOnly ) ) {
git = groups.end();
return;
}
+
+ // hack to avoid problems if big files are passed to test
+ // if they are valid configs ( like passing a mp3 ... )
+ // I just hope that there are no conf files > 100000 byte
+ // not the best solution, find something else later
+ if ( f.size() > 100000 ) {
+ return;
+ }
+
+
QTextStream s( &f );
#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
// The below should work, but doesn't in Qt 2.3.0
s.setCodec( QTextCodec::codecForMib( 106 ) );
#else
s.setEncoding( QTextStream::UnicodeUTF8 );
#endif
QStringList list = QStringList::split('\n', s.read() );
f.close();
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
if ( !parse( *it ) ) {
git = groups.end();
return;
}
}
}
/*!
\internal
*/
bool Config::parse( const QString &l )
{