kevinboone / epub2txt2

A simple command-line utility for Linux, for extracting text from EPUB documents.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't open files with double quote in path

yrps opened this issue · comments

commented

epub2txt version 2.01

Pretty easy to reproduce, or apply workaround: Take an epub and rename it.

FWIW, the error message is different if there are one or two " characters:

$ epub2txt /tmp/\"rpi\".epub
unzip:  cannot find or open /tmp/rpi.epub, /tmp/rpi.epub.zip or /tmp/rpi.epub.ZIP.
epub2txt: Can't open file '/tmp/epub2txt3109779/META-INF/container.xml' for reading: No such file or directory
$ epub2txt /tmp/rpi\".epub
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
epub2txt: Can't open file '/tmp/epub2txt3110237/META-INF/container.xml' for reading: No such file or directory

Also FYI, the latest tag at this time is 2.01 but README.md refers to 2.02.

I've pushed a change that should fix this. I'm now using execlp() to launch unzip, rather than system(). This avoid problems with the shell's handling of quotes, and probably saves a few bytes of memory. By all means test, and let me know if it's OK. TBH, it never occurred to me that anybody would uses filenames with quotes in; but I guess there's no reason not to. The next version of epub2txt will have its own unzip logic -- this utility relies too heavily on having a Unix-like shell and utilities available.
PS: I don't tag all pushes, even those that change the internal version number.

commented

I confirm the fix. Closing this now.