mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
[#2659] Make URL hook handle multiple $_GET arguments
This commit is contained in:
@ -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());
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user