From b8de4e73bf8f1497d9a100f056e8e7426e282c66 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 6 Dec 2018 12:44:13 -0500 Subject: [PATCH] Eeschema: fix schematic symbol parsing bug. Schematic symbol library link names are unquoted strings that can contain non-ascii characters which breaks the parser. Converting the line to uft-8 before breaking the string into tokens resolves the issue. --- eeschema/sch_legacy_plugin.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index c5074d721b..8e9396df8d 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -1426,8 +1426,15 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) if( strCompare( "L", line, &line ) ) { wxString libName; + size_t pos = 2; // "X" plus ' ' space character. + wxString utf8Line = wxString::FromUTF8( line ); + wxStringTokenizer tokens( utf8Line, " \r\n\t" ); - parseUnquotedString( libName, aReader, line, &line ); + if( tokens.CountTokens() < 2 ) + THROW_PARSE_ERROR( "invalid symbol library definition", aReader.GetSource(), + aReader.Line(), aReader.LineNumber(), pos ); + + libName = tokens.GetNextToken(); libName.Replace( "~", " " ); LIB_ID libId; @@ -1442,9 +1449,8 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader ) component->SetLibId( libId ); - wxString refDesignator; + wxString refDesignator = tokens.GetNextToken(); - parseUnquotedString( refDesignator, aReader, line, &line ); refDesignator.Replace( "~", " " ); wxString prefix = refDesignator;