forked from enlightenment/efl
greatly improve escape code for cnp escapes, also fixes all cnp escaping bugs
also fix another non-elm cnp crash SVN revision: 63318
This commit is contained in:
parent
1360b4df3b
commit
d2af2558dc
|
@ -153,11 +153,11 @@ static const Escape escapes[] = {
|
|||
{ "<ps>", _PARAGRAPH_SEPARATOR },
|
||||
{ "<br>", "\n" },
|
||||
{ "<\t>", "\t" },
|
||||
{ "gt;", ">" },
|
||||
{ "lt;", "<" },
|
||||
{ "amp;", "&" },
|
||||
{ "quot;", "\'" },
|
||||
{ "dquot;", "\"" }
|
||||
{ ">", ">" },
|
||||
{ "<", "<" },
|
||||
{ "&", "&" },
|
||||
{ """, "'" },
|
||||
{ "&dquot;", "\"" }
|
||||
};
|
||||
#define N_ESCAPES ((int)(sizeof(escapes) / sizeof(escapes[0])))
|
||||
|
||||
|
@ -578,7 +578,7 @@ selection_notify(void *udata __UNUSED__, int type __UNUSED__, void *event)
|
|||
|
||||
|
||||
static Eina_Bool
|
||||
targets_converter(char *target __UNUSED__, void *data, int size __UNUSED__, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize)
|
||||
targets_converter(char *target __UNUSED__, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *ttype, int *typesize)
|
||||
{
|
||||
int i,count;
|
||||
Ecore_X_Atom *aret;
|
||||
|
@ -586,6 +586,13 @@ targets_converter(char *target __UNUSED__, void *data, int size __UNUSED__, void
|
|||
|
||||
if (!data_ret) return EINA_FALSE;
|
||||
|
||||
if (size != sizeof(int))
|
||||
{
|
||||
if (data_ret) *data_ret = strndup(data, size);
|
||||
if (size_ret) *size_ret = size;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
sel = selections + *((int *)data);
|
||||
|
||||
for (i = 0, count = 0; i < CNP_N_ATOMS ; i++)
|
||||
|
@ -958,8 +965,8 @@ text_converter(char *target __UNUSED__, void *data, int size, void **data_ret, i
|
|||
cnp_debug("text converter\n");
|
||||
if (size != sizeof(int))
|
||||
{
|
||||
if (data_ret) *data_ret = strndup(data, size - 1);
|
||||
if (size_ret) *size_ret = size - 1;
|
||||
if (data_ret) *data_ret = strndup(data, size);
|
||||
if (size_ret) *size_ret = size;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
sel = selections + *((int *)data);
|
||||
|
@ -1000,8 +1007,8 @@ general_converter(char *target __UNUSED__, void *data, int size, void **data_ret
|
|||
}
|
||||
else if (size)
|
||||
{
|
||||
if (data_ret) *data_ret = strndup(data, size - 1);
|
||||
if (size_ret) *size_ret = size - 1;
|
||||
if (data_ret) *data_ret = strndup(data, size);
|
||||
if (size_ret) *size_ret = size;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
@ -1038,34 +1045,63 @@ remove_tags(const char *p, int *len)
|
|||
|
||||
while (*p)
|
||||
{
|
||||
if ((*p != '<') && (*p != '&')) *q++ = *p++;
|
||||
else if (*p == '<')
|
||||
Eina_Bool esc = EINA_TRUE;
|
||||
const char *x;
|
||||
switch (p[0])
|
||||
{
|
||||
if ((p[1] == 'b') && (p[2] == 'r') &&
|
||||
((p[3] == ' ') || (p[3] == '/') || (p[3] == '>')))
|
||||
case '<':
|
||||
x = strchr(p + 3, '>');
|
||||
if (!x)
|
||||
{
|
||||
strcpy(q, p);
|
||||
if (len) *len = strlen(ret);
|
||||
return ret;
|
||||
}
|
||||
if (memcmp(p + 1, "br", 2) && memcmp(p + 1, "ps", 2))
|
||||
{
|
||||
strncpy(q, p, x - p + 1);
|
||||
p = x + 1;
|
||||
break;
|
||||
}
|
||||
i = x - p - 1;
|
||||
if (p[i] == '/') i--;
|
||||
for (; i > 2; i++)
|
||||
{
|
||||
if (p[i] != ' ')
|
||||
{
|
||||
esc = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!esc)
|
||||
{
|
||||
strncpy(q, p, x - p + 1);
|
||||
p = x + 1;
|
||||
break;
|
||||
}
|
||||
if (p[1] == 'b')
|
||||
*q++ = '\n';
|
||||
else if ((p[1] == 'p') && (p[2] == 's') && (p[3] == '>'))
|
||||
else
|
||||
{
|
||||
strcpy(q, _PARAGRAPH_SEPARATOR);
|
||||
q += (sizeof(_PARAGRAPH_SEPARATOR)-1);
|
||||
q += sizeof(_PARAGRAPH_SEPARATOR) - 1;
|
||||
}
|
||||
while ((*p) && (*p != '>')) p++;
|
||||
p++;
|
||||
}
|
||||
else if (*p == '&')
|
||||
{
|
||||
p++;
|
||||
for (i = 0 ; i < N_ESCAPES ; i++)
|
||||
{
|
||||
if (!strncmp(p,escapes[i].escape, strlen(escapes[i].escape)))
|
||||
p = x + 1;
|
||||
break;
|
||||
case '&':
|
||||
for (i = 3 ; i < N_ESCAPES ; i++)
|
||||
{
|
||||
if (strncmp(p, escapes[i].escape, strlen(escapes[i].escape)))
|
||||
continue;
|
||||
p += strlen(escapes[i].escape);
|
||||
strcpy(q, escapes[i].value);
|
||||
q += strlen(escapes[i].value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == N_ESCAPES) *q ++= '&';
|
||||
break;
|
||||
default:
|
||||
*q++ = *p++;
|
||||
}
|
||||
}
|
||||
*q = 0;
|
||||
|
|
Loading…
Reference in New Issue