mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
bug #1781: Replaces " by ' and escape ' using '\''. context.sh should be now sh-syntax secure
(cherry picked from commit 306aff8906)
This commit is contained in:
1 parent
14147a48f3
commit
ab0c98a746
1 file changed
+11
-1
@@ -2417,7 +2417,17 @@ int VirtualMachine::generate_context(string &files, int &disk_id)
|
||||
|
||||
for (it=values.begin(); it != values.end(); it++ )
|
||||
{
|
||||
file << it->first <<"=\""<< it->second << "\"" << endl;
|
||||
//Replace every ' in value by '\''
|
||||
string escape_str(it->second);
|
||||
size_t pos = 0;
|
||||
|
||||
while ((pos = escape_str.find('\'', pos)) != string::npos)
|
||||
{
|
||||
escape_str.replace(pos,1,"'\\''");
|
||||
pos = pos + 4;
|
||||
}
|
||||
|
||||
file << it->first <<"='" << escape_str << "'" << endl;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
Reference in new issue
Block a user