diff --git a/README.md b/README.md index 981b1cb..1eb0f3b 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ # Building ## Requirements -* boost `libboost-program-options-dev` -* curl `libcurl4-gnutls-dev` +* boost +* curl ## Compile diff --git a/configure.ac b/configure.ac index 50ba09e..2a9f2d1 100644 --- a/configure.ac +++ b/configure.ac @@ -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++]) diff --git a/makefile.in b/makefile.in index 7b9a93f..7a84afa 100644 --- a/makefile.in +++ b/makefile.in @@ -7,6 +7,7 @@ CFLAGS += -std=c++11 # librarys LDLIBS = -lcurl LDLIBS += -lboost_program_options +LDLIBS += -lboost_regex # details diff --git a/src/main.cpp b/src/main.cpp index d729322..f61ae07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -198,9 +198,10 @@ int main(int argc, char **argv) { string pipeBuffer; - while(cin >> pipeBuffer) + while(getline(cin, pipeBuffer)) { message += pipeBuffer; + message += "\n"; } } else diff --git a/src/pushhandler.cpp b/src/pushhandler.cpp index 5f247de..392d9c2 100644 --- a/src/pushhandler.cpp +++ b/src/pushhandler.cpp @@ -6,11 +6,39 @@ #include #include #include +#include -#include 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;