Commit a0443f1a authored by armin's avatar armin
Browse files

added regex for newlines

parent 61b7e58e
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#include <regex>
#include <folly/FileUtil.h> #include <folly/FileUtil.h>
#include <folly/String.h> #include <folly/String.h>
...@@ -40,7 +41,8 @@ void GooglePushModel::loadApiKey() { ...@@ -40,7 +41,8 @@ void GooglePushModel::loadApiKey() {
std::string content((std::istreambuf_iterator<char>(ifs)), std::string content((std::istreambuf_iterator<char>(ifs)),
(std::istreambuf_iterator<char>())); (std::istreambuf_iterator<char>()));
if(content.length()){ if(content.length()){
GooglePushModel::mApiKey = content; std::regex newLine("([\\n]+)");
GooglePushModel::mApiKey = std::regex_replace(content,newLine,"");
}else{ }else{
std::cout<<"Error loading Google Push Key: file: /certs/google/serverKey.txt is empty or does not exist"; std::cout<<"Error loading Google Push Key: file: /certs/google/serverKey.txt is empty or does not exist";
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -183,6 +185,7 @@ bool GooglePushModel::sendMessage() { ...@@ -183,6 +185,7 @@ bool GooglePushModel::sendMessage() {
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, true); curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, true);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if(res != CURLE_OK){ if(res != CURLE_OK){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment