X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/780cccd730e73416229d87c2d437839b597d3cb7..f822acceeee524d6e37fcbcaec3d795319c58d50:/src/common/filename.cpp diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 882581cded..dd770afb71 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -1455,15 +1455,24 @@ bool wxFileName::Normalize(int flags, if ( dir == wxT("..") ) { - if ( m_dirs.IsEmpty() ) + if ( m_dirs.empty() ) { - wxLogError(_("The path '%s' contains too many \"..\"!"), - GetFullPath().c_str()); - return false; - } + // We have more ".." than directory components so far. + // Don't treat this as an error as the path could have been + // entered by user so try to handle it reasonably: if the + // path is absolute, just ignore the extra ".." because + // "/.." is the same as "/". Otherwise, i.e. for relative + // paths, keep ".." unchanged because removing it would + // modify the file a relative path refers to. + if ( !m_relative ) + continue; - m_dirs.RemoveAt(m_dirs.GetCount() - 1); - continue; + } + else // Normal case, go one step up. + { + m_dirs.pop_back(); + continue; + } } }