summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-18 13:21:15 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-18 13:21:15 +0100
commit2ccbb0e4bce7c22a44e67f2de9e5a155bd0aed86 (patch)
tree4ea69f9bf08405c742da54409508fa30d925c957 /lib
parentc76bab5d699030a22ab85b67422e5092d92fa376 (diff)
downloadabrt-2ccbb0e4bce7c22a44e67f2de9e5a155bd0aed86.tar.gz
abrt-2ccbb0e4bce7c22a44e67f2de9e5a155bd0aed86.tar.xz
abrt-2ccbb0e4bce7c22a44e67f2de9e5a155bd0aed86.zip
add support for \" escaping in config file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/RunApp.cpp4
-rw-r--r--lib/Utils/stringops.cpp25
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp
index a2aa6987..f7cbc018 100644
--- a/lib/Plugins/RunApp.cpp
+++ b/lib/Plugins/RunApp.cpp
@@ -52,6 +52,7 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs)
*/
//Can do it using chdir() in child if we'd open-code popen
string cd_and_cmd = ssprintf("cd '%s'; %s", pActionDir, cmd);
+ VERB1 log("RunApp: executing '%s'", cd_and_cmd.c_str());
FILE *fp = popen(cd_and_cmd.c_str(), "r");
if (fp == NULL)
{
@@ -65,7 +66,8 @@ void CActionRunApp::Run(const char *pActionDir, const char *pArgs)
char line[1024];
while (fgets(line, 1024, fp) != NULL)
{
- output += line;
+ if (args.size() > FILENAME)
+ output += line;
}
pclose(fp);
diff --git a/lib/Utils/stringops.cpp b/lib/Utils/stringops.cpp
index 1b3793fc..dc71b5bd 100644
--- a/lib/Utils/stringops.cpp
+++ b/lib/Utils/stringops.cpp
@@ -3,24 +3,33 @@
void parse_args(const char *psArgs, vector_string_t& pArgs, int quote)
{
unsigned ii;
- bool is_quote = false;
+ bool inside_quotes = false;
std::string item;
for (ii = 0; psArgs[ii]; ii++)
{
- if (quote != -1 && psArgs[ii] == quote)
+ if (quote != -1)
{
- is_quote = !is_quote;
+ if (psArgs[ii] == quote)
+ {
+ inside_quotes = !inside_quotes;
+ continue;
+ }
+ /* inside quotes we support escaping with \x */
+ if (inside_quotes && psArgs[ii] == '\\' && psArgs[ii+1])
+ {
+ ii++;
+ item += psArgs[ii];
+ continue;
+ }
}
- else if (psArgs[ii] == ',' && !is_quote)
+ if (psArgs[ii] == ',' && !inside_quotes)
{
pArgs.push_back(item);
item.clear();
+ continue;
}
- else
- {
- item += psArgs[ii];
- }
+ item += psArgs[ii];
}
if (item.size() != 0)