summaryrefslogtreecommitdiffabout
path: root/src/util.cc
authorMichael Krelin <hacker@klever.net>2020-10-07 22:52:19 (UTC)
committer Michael Krelin <hacker@klever.net>2020-10-07 22:52:19 (UTC)
commitc561689bf162fb22997bd88f4392f222f151c950 (patch) (side-by-side diff)
treece4656e92c379f7089f4bb72a4b10d781b61211e /src/util.cc
parent3a4530372bc95d728dbddbac788f2c1f2d03a030 (diff)
downloadkingate-c561689bf162fb22997bd88f4392f222f151c950.zip
kingate-c561689bf162fb22997bd88f4392f222f151c950.tar.gz
kingate-c561689bf162fb22997bd88f4392f222f151c950.tar.bz2
missing includesHEADmaster
Diffstat (limited to 'src/util.cc') (more/less context) (show whitespace changes)
-rw-r--r--src/util.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc
index 48e486a..76e684f 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -1,32 +1,33 @@
+#include <cstring>
#include "kingate/util.h"
#include "kingate/exception.h"
namespace kingate {
static const char *safeChars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"_-" ;
string url_encode(const string& str) {
string rv = str;
string::size_type screwed = 0;
for(;;) {
screwed = rv.find_first_not_of(safeChars,screwed);
if(screwed == string::npos)
break;
while(screwed<rv.length() && !strchr(safeChars,rv.at(screwed))) {
char danger = rv.at(screwed);
if(danger==' ') {
rv.replace(screwed++,1,1,'+');
}else{
static char tmp[4] = {'%',0,0,0};
snprintf(&tmp[1],3,"%02X",0xFF&(int)danger);
rv.replace(screwed,1,tmp,3);
screwed+=3;
}
}
}
return rv;
}