@@ -9,6 +9,10 @@ def test_4767():
99 '''
1010 Check handling of unsafe paths in `pymupdf embed-extract`.
1111 '''
12+ if os .environ .get ('PYODIDE_ROOT' ):
13+ print ('test_4767(): not running on Pyodide - cannot run child processes.' )
14+ return
15+
1216 with pymupdf .open () as document :
1317 document .new_page ()
1418 document .embfile_add (
@@ -51,34 +55,34 @@ def get_paths():
5155 paths .append (path )
5256 return paths
5357
54- cp = run (f'cd { testdir } /one/two && { sys . executable } -m pymupdf embed-extract { path } -name evil_entry' )
58+ cp = run (f'cd { testdir } /one/two && pymupdf embed-extract { path } -name evil_entry' )
5559 print (cp .stdout )
5660 assert cp .returncode
5761 assert cp .stdout == 'refusing to write stored name outside current directory: ../../test.txt\n '
5862 assert not get_paths ()
5963
60- cp = run (f'cd { testdir } /one/two && { sys . executable } -m pymupdf embed-extract { path } -name evil_entry -unsafe' )
64+ cp = run (f'cd { testdir } /one/two && pymupdf embed-extract { path } -name evil_entry -unsafe' )
6165 assert cp .returncode == 0
6266 assert cp .stdout == "saved entry 'evil_entry' as '../../test.txt'\n "
6367 paths = get_paths ()
6468 print (f'{ paths = } ' )
6569 assert paths == [f'{ testdir } /test.txt' ]
6670
67- cp = run (f'cd { testdir } /one/two && { sys . executable } -m pymupdf embed-extract { path } -name evil_entry2' )
71+ cp = run (f'cd { testdir } /one/two && pymupdf embed-extract { path } -name evil_entry2' )
6872 assert not cp .returncode
6973 assert cp .stdout == "saved entry 'evil_entry2' as 'test2.txt'\n "
7074 paths = get_paths ()
7175 print (f'{ paths = } ' )
7276 assert paths == [f'{ testdir } /test.txt' , f'{ testdir } /one/two/test2.txt' ]
7377
74- cp = run (f'cd { testdir } /one/two && { sys . executable } -m pymupdf embed-extract { path } -name evil_entry2' )
78+ cp = run (f'cd { testdir } /one/two && pymupdf embed-extract { path } -name evil_entry2' )
7579 assert cp .returncode
7680 assert cp .stdout == "refusing to overwrite existing file with stored name: test2.txt\n "
7781 paths = get_paths ()
7882 print (f'{ paths = } ' )
7983 assert paths == [f'{ testdir } /test.txt' , f'{ testdir } /one/two/test2.txt' ]
8084
81- cp = run (f'cd { testdir } /one/two && { sys . executable } -m pymupdf embed-extract { path } -name evil_entry2 -unsafe' )
85+ cp = run (f'cd { testdir } /one/two && pymupdf embed-extract { path } -name evil_entry2 -unsafe' )
8286 assert not cp .returncode
8387 assert cp .stdout == "saved entry 'evil_entry2' as 'test2.txt'\n "
8488 paths = get_paths ()
0 commit comments