fixed bug #1509909 - !system & !packhdr fail with quotes

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4711 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2006-07-30 10:29:23 +00:00
parent e4432fd8e1
commit b15cf04ef2
4 changed files with 31 additions and 2 deletions

View file

@ -2191,7 +2191,7 @@ int CEXEBuild::pack_exe_header()
}
fwrite(m_exehead,1,m_exehead_size,tmpfile);
fclose(tmpfile);
if (system(build_packcmd) == -1)
if (sane_system(build_packcmd) == -1)
{
remove(build_packname);
ERROR_MSG("Error: calling packer on \"%s\"\n",build_packname);

View file

@ -2790,7 +2790,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
if (!success && comp != 4) PRINTHELP()
SCRIPT_MSG("!system: \"%s\"\n",exec);
#ifdef _WIN32
int ret=system(exec);
int ret=sane_system(exec);
#else
char *execfixed = my_convert(exec);
int ret=system(execfixed);

View file

@ -692,3 +692,30 @@ string lowercase(const string &str) {
transform(str.begin(), str.end(), result.begin(), tolower);
return result;
}
int sane_system(const char *command) {
#ifdef _WIN32
// workaround for bug #1509909
// http://sf.net/tracker/?func=detail&atid=373085&aid=1509909&group_id=22049
//
// cmd.exe /C has some weird handling for quotes. it strips
// the surrounding quotes, if they exist. if there are quotes
// around the program path and its arguments, it will strip
// the outer quotes. this may result in something like:
// `program files\nsis\makensis.exe" "args`
// which obviously fails...
//
// to avoid the stripping, a harmless string is prefixed
// to the command line.
string command_s = "IF 1==1 ";
command_s += command;
return system(command_s.c_str());
#else
return system(command);
#endif
}

View file

@ -45,6 +45,8 @@ std::string lowercase(const std::string&);
std::string get_string_prefix(const std::string& str, const std::string& separator);
std::string get_string_suffix(const std::string& str, const std::string& separator);
int sane_system(const char *command);
#ifndef _WIN32
char *CharPrev(const char *s, const char *p);
char *CharNext(const char *s);