1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_filename_purify_inplace

This commit is contained in:
Andy Green 2018-03-29 09:28:41 +08:00
parent 764d0d3b45
commit 3a020c1eab
2 changed files with 32 additions and 0 deletions

View file

@ -2850,6 +2850,27 @@ lws_json_purify(char *escaped, const char *string, int len)
return escaped;
}
LWS_VISIBLE LWS_EXTERN void
lws_filename_purify_inplace(char *filename)
{
while (*filename) {
if (*filename == '.' && filename[1] == '.') {
*filename = '_';
filename[1] = '_';
}
if (*filename == ':' ||
*filename == '/' ||
*filename == '\\' ||
*filename == '$' ||
*filename == '%')
*filename = '_';
filename++;
}
}
LWS_VISIBLE LWS_EXTERN const char *
lws_urlencode(char *escaped, const char *string, int len)
{

View file

@ -4426,6 +4426,17 @@ lws_sql_purify(char *escaped, const char *string, int len);
LWS_VISIBLE LWS_EXTERN const char *
lws_json_purify(char *escaped, const char *string, int len);
/**
* lws_filename_purify_inplace() - replace scary filename chars with underscore
*
* \param filename: filename to be purified
*
* Replace scary characters in the filename (it should not be a path)
* with underscore, so it's safe to use.
*/
LWS_VISIBLE LWS_EXTERN void
lws_filename_purify_inplace(char *filename);
LWS_VISIBLE LWS_EXTERN int
lws_plat_write_cert(struct lws_vhost *vhost, int is_key, int fd, void *buf,
int len);