eeschema, DIALOG_SHEET_PROPERTIES: add test for valid sheet filename

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18981
This commit is contained in:
jean-pierre charras
2024-10-25 11:44:29 +02:00
parent 8dda9b37fa
commit 82ff2c0e0f
3 changed files with 45 additions and 1 deletions
+28
View File
@@ -45,6 +45,34 @@
static const char illegalFileNameChars[] = "\\/:\"<>|*?";
// Checks if a full filename is valid, i.e. does not contains illegal chars
bool IsFullFileNameValid( const wxString& aFullFilename )
{
// Test for forbidden chars in aFullFilename.
// '\'and '/' are allowed here because aFullFilename can be a full path, and
// ':' is allowed on Windows as second char in string.
// So remove allowed separators from string to test
wxString filtered_fullpath = aFullFilename;
#ifdef __WINDOWS__
// On MSW, the list returned by wxFileName::GetForbiddenChars() contains separators
// '\'and '/'
filtered_fullpath.Replace( "/", "_" );
filtered_fullpath.Replace( "\\", "_" );
// A disk identifier is allowed, and therefore remove its separator
if( filtered_fullpath.Length() > 1 && filtered_fullpath[1] == ':' )
filtered_fullpath[1] = ' ';
#endif
if( wxString::npos != filtered_fullpath.find_first_of( wxFileName::GetForbiddenChars() ) )
return false;
return true;
}
wxString ConvertToNewOverbarNotation( const wxString& aOldStr )
{
wxString newStr;