Escape quotes to prevent break-out.

Fixes https://gitlab.com/kicad/code/kicad/issues/9236
This commit is contained in:
Jeff Young 2021-10-13 17:09:01 +01:00
parent 07b9e2ee51
commit 1b6c4638ca
2 changed files with 13 additions and 9 deletions

View File

@ -36,6 +36,7 @@
#include <confirm.h> #include <confirm.h>
#include <core/arraydim.h> #include <core/arraydim.h>
#include <gestfich.h> #include <gestfich.h>
#include <string_utils.h>
void QuoteString( wxString& string ) void QuoteString( wxString& string )
{ {
@ -261,14 +262,14 @@ bool doPrintFile( const wxString& file, bool aDryRun )
if( !application.IsEmpty() ) if( !application.IsEmpty() )
{ {
wxString ascript; // Use concatenation to avoid double-quote bug in wxWidgets 3.1.5 OSX.
ascript.Printf( "osascript -e 'tell application \"%s\"' " wxString ascript = "osascript -e 'tell application \""
"-e ' set srcFileRef to (open POSIX file \"%s\")' " + EscapeString( application, CTX_QUOTED_STR ) + "\"' "
"-e ' activate' " + "-e ' set srcFileRef to (open POSIX file \""
"-e ' print srcFileRef print dialog true' " + EscapeString( file, CTX_QUOTED_STR ) + "\")' "
"-e 'end tell' ", + "-e ' activate' "
application, + "-e ' print srcFileRef print dialog true' "
file ); + "-e 'end tell' ";
if( !aDryRun ) if( !aDryRun )
wxExecute( ascript ); wxExecute( ascript );

View File

@ -31,6 +31,7 @@
#include <tools/kicad_manager_control.h> #include <tools/kicad_manager_control.h>
#include <dialogs/dialog_template_selector.h> #include <dialogs/dialog_template_selector.h>
#include <gestfich.h> #include <gestfich.h>
#include <string_utils.h>
#include <paths.h> #include <paths.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/dir.h> #include <wx/dir.h>
@ -789,7 +790,9 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
m_frame->PrintMsg( msg ); m_frame->PrintMsg( msg );
#ifdef __WXMAC__ #ifdef __WXMAC__
wxExecute( wxString::Format( "osascript -e 'activate application \"%s\"' ", execFile ) ); // Use concatenation to avoid double-quote bug in wxWidgets 3.1.5 OSX.
wxExecute( "osascript -e 'activate application \""
+ EscapeString( execFile, CTX_QUOTED_STR ) + "\"' " );
#endif #endif
} }
else else