From ef510adea5995e7cacee2697b389c48bd9b19f70 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 20 Nov 2013 13:53:04 +0100 Subject: [PATCH] adequately shell-escape generated sed commands Change-Id: I39c8c4ab3da69bd21beace56f5cf3070301ac015 Reviewed-by: Joerg Bornemann --- qmake/generators/makefile.cpp | 12 +++++++++++- qmake/generators/makefile.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index f628ca7ac4e..d88c6e447ae 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -43,6 +43,9 @@ #include "option.h" #include "cachekeys.h" #include "meta.h" + +#include + #include #include #include @@ -52,6 +55,7 @@ #include #include #include + #if defined(Q_OS_UNIX) #include #else @@ -3345,11 +3349,17 @@ QString MakefileGenerator::installMetaFile(const ProKey &replace_rule, const QSt const ProString match = project->first(ProKey(replace_rules.at(r) + ".match")), replace = project->first(ProKey(replace_rules.at(r) + ".replace")); if (!match.isEmpty() /*&& match != replace*/) - ret += " -e \"s," + match + "," + replace + ",g\""; + ret += " -e " + shellQuote("s," + match + "," + replace + ",g"); } ret += " \"" + src + "\" >\"" + dst + "\""; } return ret; } +QString MakefileGenerator::shellQuote(const QString &str) +{ + return isWindowsShell() ? QMakeInternal::IoUtils::shellQuoteWin(str) + : QMakeInternal::IoUtils::shellQuoteUnix(str); +} + QT_END_NAMESPACE diff --git a/qmake/generators/makefile.h b/qmake/generators/makefile.h index 09327c599c3..4b8a96c15f0 100644 --- a/qmake/generators/makefile.h +++ b/qmake/generators/makefile.h @@ -271,6 +271,7 @@ public: virtual bool mergeBuildProject(MakefileGenerator * /*other*/) { return false; } virtual bool openOutput(QFile &, const QString &build) const; bool isWindowsShell() const { return Option::dir_sep == QLatin1String("\\"); } + QString shellQuote(const QString &str); }; inline void MakefileGenerator::setNoIO(bool o)