Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaped wildcards while unzipping #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

lvvz
Copy link

@lvvz lvvz commented Aug 29, 2020

Directory may contain files/directories with wild names.
To be handled by Common Lisp (on unzip), some characters must be preceded by #\\.
For instance, here is for #\[:

CL-USER>
(let ((dir #P"/tmp/arch098765/"))
  (ensure-directories-exist dir)
  (alexandria:write-string-into-file " "
				     (cl-fad:merge-pathnames-as-file dir #P"\\[a].html")
				     :if-exists :supersede)
  (zip:zip #P"/tmp/arch098765.zip" dir :if-exists :supersede)
  (zip:unzip #P"/tmp/arch098765.zip" #P"/tmp/arch098765-1/" :if-exists :supersede))

But names lose backslashes by sb-impl::native-namestring when zipped, so failing on unzip:

bad place for a wild pathname
   [Condition of type SB-INT:SIMPLE-FILE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1001FC7FA3}>)

Backtrace:
  0: (ENSURE-DIRECTORIES-EXIST #P"/tmp/arch098765-1/[a].html" :VERBOSE NIL :MODE 511)
  1: (ZIP:UNZIP #P"/tmp/arch098765.zip" #P"/tmp/arch098765-1/" :IF-EXISTS :SUPERSEDE :VERBOSE NIL :FORCE-UTF-8 NIL)

To restore backslashes sb-impl::parse-native-namestring has been used.
This fix is supposed to cover SBCL at least. Actually, I got no idea whether this problem comes up on other implementations.

After directory is zipped, all backslashes are removed by sbcl-impl::native-namestring. Thus to successfully unzip, call sb-impl::parse-native-namestring.
@lvvz lvvz changed the title Unescaped wildcards while unzipping Escaped wildcards while unzipping Aug 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant