25#include <boost/test/tools/old/interface.hpp>
58static const std::vector<WX_FILENAME_SPLIT_CASE>
split_cases = {
89 "/tmp/example/name.ext",
105 "/tmp/example/name.ext1.ext2",
117 std::stringstream ss;
118 ss << c.m_path <<
", " << c.m_name;
136 wxT(
"a/../../evil" ),
137 wxT(
"plugins/../../../../tmp/PCM_PWNED" ),
138 wxT(
"../../../../tmp/PWNED" ),
139 wxT(
"a/b/../../../evil" ),
141 wxT(
"/etc/passwd" ),
142 wxT(
"//etc/passwd" ),
146 wxT(
"plugins\\..\\..\\..\\tmp\\PCM_PWNED" ),
147 wxT(
"\\\\server\\share\\evil" ),
154 { wxT(
"board.kicad_pcb" ), wxT(
"board.kicad_pcb" ) },
155 { wxT(
"./board.kicad_pcb" ), wxT(
"board.kicad_pcb" ) },
156 { wxT(
"sub/board.kicad_pcb" ), wxT(
"sub/board.kicad_pcb" ) },
157 { wxT(
"sub//board.kicad_pcb" ), wxT(
"sub/board.kicad_pcb" ) },
158 { wxT(
"sub/./deep/board.kicad_pcb" ), wxT(
"sub/deep/board.kicad_pcb" ) },
159 { wxT(
"a..b/c.kicad_sch" ), wxT(
"a..b/c.kicad_sch" ) },
160 { wxT(
"...leading/x.txt" ), wxT(
"...leading/x.txt" ) },
195 const wxString dest = wxFileName::GetTempDir() + wxFileName::GetPathSeparator() + wxT(
"kicad-unarchive-dest" );
211 const wxString dest = wxFileName::GetTempDir() + wxFileName::GetPathSeparator() + wxT(
"kicad-unarchive-dest" );
212 const wxString destWithSep = wxFileName::DirName( dest ).GetPathWithSep();
221 BOOST_CHECK( resolved.GetFullPath().StartsWith( destWithSep ) );
223 wxFileName relative = resolved;
224 relative.MakeRelativeTo( dest );
248 const std::vector<wxString> nested_names = {
249 wxT(
"sub/board.kicad_pcb" ),
250 wxT(
"./board.kicad_pcb" ),
251 wxT(
"sub/./deep/board.kicad_pcb" ),
252 wxT(
"board.kicad_pcb/" ),
255 for(
const wxString&
name : nested_names )
268 const std::vector<wxString> child_names = {
269 wxT(
"board.kicad_pcb" ),
272 wxT(
"name with spaces.txt" ),
275 for(
const wxString&
name : child_names )
A wrapper around a wxFileName which is much more performant with a subset of the API.
static bool IsSafeChildPath(const wxString &aChild)
Check that a child path is safe to append to a parent directory.
static bool ResolveArchiveEntryPath(const wxString &aDestDir, const wxString &aEntryName, wxFileName &aResult)
Resolve an untrusted archive entry name against the directory it is extracted into.
static bool SplitArchiveEntryName(const wxString &aEntryName, wxArrayString &aParts)
Split an untrusted archive entry name into its path components.
wxString GetFullPath() const
wxString GetFullName() const
std::string m_exp_full_name
std::string m_exp_full_path
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
static const std::vector< WX_FILENAME_SPLIT_CASE > split_cases
static const std::vector< wxString > hostile_entry_names
static const std::vector< std::pair< wxString, wxString > > benign_entry_names
BOOST_AUTO_TEST_CASE(Split)
Check the various split cases work correctly.