fix const on hyperlink urls

This commit is contained in:
Boris Faure 2018-10-13 22:05:48 +02:00
parent dc5c291bb9
commit a11c591cce
4 changed files with 22 additions and 10 deletions

View File

@ -56,7 +56,7 @@ _tooltip_del(void *data,
}
void
gravatar_tooltip(Evas_Object *obj, const Config *config, char *email)
gravatar_tooltip(Evas_Object *obj, const Config *config, const char *email)
{
int n;
MD5_CTX ctx;
@ -65,18 +65,29 @@ gravatar_tooltip(Evas_Object *obj, const Config *config, char *email)
static const char hex[] = "0123456789abcdef";
const char *url;
Gravatar *g;
size_t len;
char *str;
if (!config->gravatar)
return;
g = calloc(sizeof(Gravatar), 1);
if (!g) return;
if (!g)
return;
g->config = config;
eina_str_tolower(&email);
len = strlen(email);
str = strndup(email, len);
if (!str)
{
free(g);
return;
}
eina_str_tolower(&str);
MD5Init(&ctx);
MD5Update(&ctx, (unsigned char const*)email, (unsigned)strlen(email));
MD5Update(&ctx, (unsigned char const*)str, (unsigned)len);
MD5Final(hash, &ctx);
for (n = 0; n < MD5_HASHBYTES; n++)
@ -93,6 +104,7 @@ gravatar_tooltip(Evas_Object *obj, const Config *config, char *email)
elm_object_tooltip_content_cb_set(obj, _tooltip_content,
g,
_tooltip_del);
free(str);
}
void

View File

@ -4,7 +4,7 @@
#include "config.h"
void
gravatar_tooltip(Evas_Object *obj, const Config *config, char *email);
gravatar_tooltip(Evas_Object *obj, const Config *config, const char *email);
void gravatar_init(void);
void gravatar_shutdown(void);

View File

@ -7,8 +7,8 @@ typedef struct _Termlink Term_Link;
struct _Termlink
{
char *key;
char *url;
const char *key;
const char *url;
unsigned int refcount;
};

View File

@ -1806,8 +1806,8 @@ _handle_hyperlink(Termpty *ty,
char *s,
int len)
{
char *url = NULL;
char *key = NULL;
const char *url = NULL;
const char *key = NULL;
Term_Link *hl = NULL;
if (!s || len <= 0)
@ -1848,7 +1848,7 @@ _handle_hyperlink(Termpty *ty,
if (len > 3 && strncmp(s, "id=", 3) == 0)
{
free(key);
eina_stringshare_del(key);
s += 3;
len -= 3;