diff --git a/sflphone-common/src/hooks/urlhook.cpp b/sflphone-common/src/hooks/urlhook.cpp index b50aa1febbf33ecaefc5d681f0d7330ffda035d8..3538602fb773a926d74162f49e9b8e6ff8942fe5 100644 --- a/sflphone-common/src/hooks/urlhook.cpp +++ b/sflphone-common/src/hooks/urlhook.cpp @@ -19,6 +19,7 @@ #include "urlhook.h" #include <iostream> +#include <vector> UrlHook::UrlHook () { } @@ -28,9 +29,33 @@ int UrlHook::addAction (std::string field_value, std::string command) { std::string command_bg; + std::string temp; + std::vector <std::string> args; + size_t pos; + unsigned int i; + + /* Escape the '&' char to not discard $_GET parameters in the URL - #2659 */ + while ( (pos = field_value.find ("&", 0)) != std::string::npos) { + temp = field_value.substr (0, pos); + field_value.erase (0, pos + 1); + args.push_back (temp); + std::cout << temp << " " << std::endl; + } + + command_bg = command + " "; + + pos = args.size (); + for (i=0; i<pos; i++) { + // Escape the "&" + command_bg += args[i] + "\\&"; + } + + // Retrieve the last argument + command_bg += field_value; /* Execute the command in the background to not block the application */ - command_bg = command + " " + field_value + "&" ; + command_bg += "&"; + /* Execute a system call */ return RUN_COMMAND (command_bg.c_str()); diff --git a/sflphone-common/test/hookmanagerTest.cpp b/sflphone-common/test/hookmanagerTest.cpp index d5b8cb6a80a4a0fcca0e55c7440a0853d443b66f..817533a9277592570a8c2b5db7e5e7c0630dcd62 100644 --- a/sflphone-common/test/hookmanagerTest.cpp +++ b/sflphone-common/test/hookmanagerTest.cpp @@ -38,7 +38,7 @@ void HookManagerTest::testAddAction () int status; - status = urlhook->addAction ("www.google.ca", "x-www-browser"); + status = urlhook->addAction ("http://www.google.ca/?arg1=arg1&arg2=nvls&x=2&y=45&z=1", "x-www-browser"); CPPUNIT_ASSERT (status == 0); }