mirror of
https://github.com/HackHerz/pusher
synced 2025-12-06 02:10:19 +00:00
Added url-decoding
This commit is contained in:
parent
d11867f430
commit
e242b208db
5 changed files with 36 additions and 5 deletions
|
|
@ -5,8 +5,8 @@
|
|||
# Building
|
||||
## Requirements
|
||||
|
||||
* boost `libboost-program-options-dev`
|
||||
* curl `libcurl4-gnutls-dev`
|
||||
* boost
|
||||
* curl
|
||||
|
||||
## Compile
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ AC_LANG_PUSH([C++])
|
|||
AC_CHECK_HEADERS([boost/property_tree/ptree.hpp], [], [AC_MSG_ERROR(You need the Boost libraries.)])
|
||||
AC_CHECK_HEADERS([boost/property_tree/ini_parser.hpp], [], [AC_MSG_ERROR(You need the Boost libraries.)])
|
||||
AC_CHECK_HEADERS([boost/program_options.hpp], [], [AC_MSG_ERROR(You need the Boost Program Options library.)])
|
||||
AC_CHECK_HEADERS([boost/regex.hpp], [], [AC_MSG_ERROR(You need the Boost Regex library.)])
|
||||
AC_CHECK_HEADERS([curl/curl.h], [], [AC_MSG_ERROR(You need the curl libraries.)])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ CFLAGS += -std=c++11
|
|||
# librarys
|
||||
LDLIBS = -lcurl
|
||||
LDLIBS += -lboost_program_options
|
||||
LDLIBS += -lboost_regex
|
||||
|
||||
|
||||
# details
|
||||
|
|
|
|||
|
|
@ -198,9 +198,10 @@ int main(int argc, char **argv)
|
|||
{
|
||||
string pipeBuffer;
|
||||
|
||||
while(cin >> pipeBuffer)
|
||||
while(getline(cin, pipeBuffer))
|
||||
{
|
||||
message += pipeBuffer;
|
||||
message += "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -6,11 +6,39 @@
|
|||
#include <boost/foreach.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// urlDecode matches
|
||||
const char* matches[][2] = {
|
||||
{"\\$", "%24"},
|
||||
{"\\&", "%26"},
|
||||
{"\\+", "%2B"},
|
||||
{"\\,", "%2C"},
|
||||
{"\\/", "%2F"},
|
||||
{"\\:", "%3A"},
|
||||
{"\\;", "%3B"},
|
||||
{"\\=", "%3D"},
|
||||
{"\\?", "%3F"},
|
||||
{"\\@", "%40"}
|
||||
};
|
||||
|
||||
// neded for urlencoding
|
||||
string urlDecode(string url)
|
||||
{
|
||||
for(unsigned int i = 0; i < (sizeof(matches)/sizeof(matches[0])); i++)
|
||||
{
|
||||
boost::regex reg(matches[i][0]);
|
||||
url = boost::regex_replace(url, reg, matches[i][1]);
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
// needed for handling curl output
|
||||
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
|
|
@ -191,7 +219,7 @@ void PushHandler::sendToDevice(int id, string message)
|
|||
% APP_PACKAGE
|
||||
% id
|
||||
% "MESSAGE"
|
||||
% message;
|
||||
% urlDecode(message);
|
||||
|
||||
// network request
|
||||
string readBuffer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue