Skip to content
Snippets Groups Projects
Commit be9e4c79 authored by Matthias Breithaupt's avatar Matthias Breithaupt Committed by Mark Roszko
Browse files

CLI: Sanitize filename when exporting symbol as svg

When using symbol names as filenames, invalid characters and
characters that might be mis-interpreted (e.g. '/') have to be
removed from the name to prevent unexpected behavior.

Fixes: kicad/code/kicad#15751
parent 6b12a12b
No related branches found
No related tags found
No related merge requests found
Pipeline #1019686031 skipped
......@@ -579,14 +579,23 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
{
wxString filename;
wxFileName fn;
size_t forbidden_char;
fn.SetPath( aSvgJob->m_outputDirectory );
fn.SetExt( SVGFileExtension );
filename = symbol->GetName().Lower();
while( wxString::npos
!= ( forbidden_char = filename.find_first_of(
wxFileName::GetForbiddenChars( wxPATH_DOS ) ) ) )
{
filename = filename.replace( forbidden_char, 1, wxS( '_' ) );
}
//simplify the name if its single unit
if( symbol->IsMulti() )
{
filename = wxString::Format( "%s_%d", symbol->GetName().Lower(), unit );
filename += wxString::Format( "_%d", unit );
if( convert == 2 )
filename += wxS( "_demorgan" );
......@@ -598,8 +607,6 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob,
}
else
{
filename = symbol->GetName().Lower();
if( convert == 2 )
filename += wxS( "_demorgan" );
......@@ -912,4 +919,4 @@ DS_PROXY_VIEW_ITEM* EESCHEMA_JOBS_HANDLER::getDrawingSheetProxyView( SCHEMATIC*
drawingSheet->SetSheetPath( "" );
return drawingSheet;
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment