From f9f671d1b972d23fccd05ab2d068d9576b16408c Mon Sep 17 00:00:00 2001 From: charras Date: Thu, 13 Aug 2009 18:50:47 +0000 Subject: [PATCH] fixed: incorrect sub path calculation for libs and doc filenames (full filenames where always converted to relative paths, even when they are not in standard libraries paths) --- common/edaappl.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/edaappl.cpp b/common/edaappl.cpp index 5cd873e512..126593fb26 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -998,7 +998,7 @@ void WinEDA_App::SaveLastVisitedLibraryPath( const wxString& aPath ) /** ReturnFilenameWithRelativePathInLibPath * @return a short filename (with extension) with only a relative path if this filename - * can be found in library paths + * can be found in library paths (i.e. if the path is a sub path of a libraries path) * @param aFullFilename = filename with path and extension. */ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename ) @@ -1008,7 +1008,8 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF * the library name with the full or relative path. * the relative path, when possible is preferable, * because it preserve use of default libraries paths, when the path is a sub path of these default paths - * + * Note we accept only sub paths, + * not relative paths starting by ../ that are not subpaths and are outside kicad libs paths */ wxFileName fn = aFullFilename; wxString filename = aFullFilename; @@ -1023,8 +1024,10 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF { if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) ) { - if( pathlen < 0 // a subpath is found - || pathlen > (int) fn.GetPath().Len() ) // a better subpath if found + if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths + continue; + if( pathlen < 0 // a first subpath is found + || pathlen > (int) fn.GetPath().Len() ) // or a better subpath if found { filename = fn.GetPathWithSep() + fn.GetFullName(); pathlen = fn.GetPath().Len();