Merge pull request #1826 from connortechnology/uri_decode_in_zms
Uri decode in zms
This commit is contained in:
commit
b609b9ad4c
|
@ -25,6 +25,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CURL_CURL_H
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned int sseversion = 0;
|
unsigned int sseversion = 0;
|
||||||
|
|
||||||
std::string trimSet(std::string str, std::string trimset) {
|
std::string trimSet(std::string str, std::string trimset) {
|
||||||
|
@ -345,3 +349,18 @@ void timespec_diff(struct timespec *start, struct timespec *end, struct timespec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string UriDecode( const std::string &encoded ) {
|
||||||
|
#ifdef HAVE_LIBCURL
|
||||||
|
CURL *curl = curl_easy_init();
|
||||||
|
int outlength;
|
||||||
|
char *cres = curl_easy_unescape(curl, encoded.c_str(), encoded.length(), &outlength);
|
||||||
|
std::string res(cres, cres + outlength);
|
||||||
|
curl_free(cres);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
return res;
|
||||||
|
#else
|
||||||
|
Warning("ZM Compiled without LIBCURL. UriDecoding not implemented.");
|
||||||
|
return encoded;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,4 +60,6 @@ void timespec_diff(struct timespec *start, struct timespec *end, struct timespec
|
||||||
|
|
||||||
extern unsigned int sseversion;
|
extern unsigned int sseversion;
|
||||||
|
|
||||||
|
std::string UriDecode( const std::string &encoded );
|
||||||
|
|
||||||
#endif // ZM_UTILS_H
|
#endif // ZM_UTILS_H
|
||||||
|
|
18
src/zms.cpp
18
src/zms.cpp
|
@ -69,8 +69,8 @@ int main( int argc, const char *argv[] )
|
||||||
unsigned int bitrate = 100000;
|
unsigned int bitrate = 100000;
|
||||||
unsigned int ttl = 0;
|
unsigned int ttl = 0;
|
||||||
EventStream::StreamMode replay = EventStream::MODE_SINGLE;
|
EventStream::StreamMode replay = EventStream::MODE_SINGLE;
|
||||||
char username[64] = "";
|
std::string username;
|
||||||
char password[64] = "";
|
std::string password;
|
||||||
char auth[64] = "";
|
char auth[64] = "";
|
||||||
unsigned int connkey = 0;
|
unsigned int connkey = 0;
|
||||||
unsigned int playback_buffer = 0;
|
unsigned int playback_buffer = 0;
|
||||||
|
@ -164,7 +164,7 @@ int main( int argc, const char *argv[] )
|
||||||
{
|
{
|
||||||
if ( !strcmp( name, "user" ) )
|
if ( !strcmp( name, "user" ) )
|
||||||
{
|
{
|
||||||
strncpy( username, value, sizeof(username) );
|
username = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -180,11 +180,11 @@ int main( int argc, const char *argv[] )
|
||||||
{
|
{
|
||||||
if ( !strcmp( name, "user" ) )
|
if ( !strcmp( name, "user" ) )
|
||||||
{
|
{
|
||||||
strncpy( username, value, sizeof(username) );
|
username = UriDecode(value);
|
||||||
}
|
}
|
||||||
if ( !strcmp( name, "pass" ) )
|
if ( !strcmp( name, "pass" ) )
|
||||||
{
|
{
|
||||||
strncpy( password, value, sizeof(password) );
|
password = UriDecode( password );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,9 +198,9 @@ int main( int argc, const char *argv[] )
|
||||||
|
|
||||||
if ( strcmp( config.auth_relay, "none" ) == 0 )
|
if ( strcmp( config.auth_relay, "none" ) == 0 )
|
||||||
{
|
{
|
||||||
if ( *username )
|
if ( username.length() )
|
||||||
{
|
{
|
||||||
user = zmLoadUser( username );
|
user = zmLoadUser( username.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -214,9 +214,9 @@ int main( int argc, const char *argv[] )
|
||||||
}
|
}
|
||||||
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
//else if ( strcmp( config.auth_relay, "plain" ) == 0 )
|
||||||
{
|
{
|
||||||
if ( *username && *password )
|
if ( username.length() && password.length() )
|
||||||
{
|
{
|
||||||
user = zmLoadUser( username, password );
|
user = zmLoadUser( username.c_str(), password.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue