Skip to content
Permalink
Browse files

Fixing potentially very long field names when reading arbitrary data …

…from CSV files - reduced max length to 200
  • Loading branch information
ccrook committed Apr 26, 2013
1 parent 6ba9f4d commit 56f4a5eb081caa9c57d00f2819dfb186a6b7ca54
@@ -43,6 +43,7 @@ QgsDelimitedTextFile::QgsDelimitedTextFile( QString url ) :
mTrimFields( false ),
mSkipLines( 0 ),
mMaxFields( 0 ),
mMaxNameLength( 200 ), // Don't want field names to be too unweildy!
mLineNumber( 0 ),
mRecordLineNumber( 0 ),
mMaxFieldCount( 0 )
@@ -377,6 +378,7 @@ void QgsDelimitedTextFile::setFieldNames( const QStringList &names )
bool nameOk = true;
int fieldNo = mFieldNames.size() + 1;
name = name.trimmed();
if( name.length() > mMaxNameLength ) name=name.mid(0,mMaxNameLength );

// If the name is invalid then reset it to default name
if ( InvalidFieldRegexp.exactMatch( name ) )
@@ -322,6 +322,7 @@ class QgsDelimitedTextFile
bool mTrimFields;
int mSkipLines;
int mMaxFields;
int mMaxNameLength;

// Parameters used by parsers
QRegExp mDelimRegexp;

0 comments on commit 56f4a5e

Please sign in to comment.
You can’t perform that action at this time.