Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 56f4a5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 ) )
Expand Down
1 change: 1 addition & 0 deletions src/providers/delimitedtext/qgsdelimitedtextfile.h
Expand Up @@ -322,6 +322,7 @@ class QgsDelimitedTextFile
bool mTrimFields;
int mSkipLines;
int mMaxFields;
int mMaxNameLength;

// Parameters used by parsers
QRegExp mDelimRegexp;
Expand Down

0 comments on commit 56f4a5e

Please sign in to comment.