Commit f9f671d1 authored by charras's avatar charras

fixed: incorrect sub path calculation for libs and doc filenames (full...

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)
parent 8aca4b3c
...@@ -998,7 +998,7 @@ void WinEDA_App::SaveLastVisitedLibraryPath( const wxString& aPath ) ...@@ -998,7 +998,7 @@ void WinEDA_App::SaveLastVisitedLibraryPath( const wxString& aPath )
/** ReturnFilenameWithRelativePathInLibPath /** ReturnFilenameWithRelativePathInLibPath
* @return a short filename (with extension) with only a relative path if this filename * @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. * @param aFullFilename = filename with path and extension.
*/ */
wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename ) wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename )
...@@ -1008,7 +1008,8 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF ...@@ -1008,7 +1008,8 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF
* the library name with the full or relative path. * the library name with the full or relative path.
* the relative path, when possible is preferable, * 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 * 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; wxFileName fn = aFullFilename;
wxString filename = aFullFilename; wxString filename = aFullFilename;
...@@ -1023,8 +1024,10 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF ...@@ -1023,8 +1024,10 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF
{ {
if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) ) if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) )
{ {
if( pathlen < 0 // a subpath is found if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
|| pathlen > (int) fn.GetPath().Len() ) // a better subpath if found 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(); filename = fn.GetPathWithSep() + fn.GetFullName();
pathlen = fn.GetPath().Len(); pathlen = fn.GetPath().Len();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment