[MPlayer-dev-eng] [PATCH] Use unrar for open vobsubs if available
Ulion
ulion2002 at gmail.com
Tue Dec 11 15:16:32 CET 2007
2007/12/7, Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Thu, Dec 06, 2007 at 11:20:14PM +0800, Ulion wrote:
> [...]
> > I really don't like writing windows api code, anyone can save me? I'd
> > like to use popen on mingw if no one want to write that part of
> > CreateProcess code for it. On the other hand, once the executable is a
> > pre-tested existed file and command line parameters are correctly
> > escaped, there's no obvious security problem to use popen on win32.
>
> The escaping rules for Windows are rather weird, and at least I don't easily
> feel confident to say that I know all the small hacks they introduced.
OK, I found the microsoft specific document for parsing and construct
command line:
http://msdn2.microsoft.com/en-us/library/ms880421.aspx
Microsoft Specific ―>
Microsoft C startup code uses the following rules when interpreting
arguments given on the operating system command line:
* Arguments are delimited by white space, which is either a space or a tab.
* A string surrounded by double quotation marks is interpreted as
a single argument, regardless of white space contained within. A
quoted string can be embedded in an argument. Note that the caret (^)
is not recognized as an escape character or delimiter.
* A double quotation mark preceded by a backslash, \", is
interpreted as a literal double quotation mark (").
* Backslashes are interpreted literally, unless they immediately
precede a double quotation mark.
* If an even number of backslashes is followed by a double
quotation mark, then one backslash (\) is placed in the argv array for
every pair of backslashes (\\), and the double quotation mark (") is
interpreted as a string delimiter.
* If an odd number of backslashes is followed by a double
quotation mark, then one backslash (\) is placed in the argv array for
every pair of backslashes (\\) and the double quotation mark is
interpreted as an escape sequence by the remaining backslash, causing
a literal double quotation mark (") to be placed in argv.
After read the document, maybe you think use quotes is better, but
unfortunately the quotes did not keep '%' as a literal character (try
'%OS% in your command line and test.) and % can not be escaped within
quotes. That can be fixed by replace % with "%" or "^%" (include the
quotes, but you should known % is not within quotes, it's between two
pair quotes,)
Then I choose to use current escape method, mainly use ^ to escape all
possible special characters, and use quotes for spaces and tabs, and
take good care of literal quotation and backslashes. That will works
and robost.
Here's my updated patch.
--
Ulion
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unrar_exec15.diff
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20071211/844f5e5e/attachment.txt>
More information about the MPlayer-dev-eng
mailing list