If unicode_get_utf8 returns -1, assume it was actually undeclared

* e-html-utils.c (e_text_to_html): If unicode_get_utf8 returns -1,
	assume it was actually undeclared iso-8859-1 text.

svn path=/trunk/; revision=6002
This commit is contained in:
Dan Winship
2000-10-18 18:59:21 +00:00
parent 4af109915a
commit c03848ecdf
2 changed files with 18 additions and 58 deletions

View File

@ -1,12 +1,18 @@
2000-10-18 Dan Winship <danw@helixcode.com>
* e-html-utils.c (e_text_to_html): If unicode_get_utf8 returns -1,
assume it was actually undeclared iso-8859-1 text.
2000-10-17 Jesse Pavel <jpavel@helixcode.com> 2000-10-17 Jesse Pavel <jpavel@helixcode.com>
* ename/e-address-western.c: made the routines use the stardard e_strstrcase * ename/e-address-western.c: made the routines use the stardard
instead of the included function that existed earlier. e_strstrcase instead of the included function that existed
earlier.
2000-10-11 Iain Holmes <iain@helixcode.com> 2000-10-11 Iain Holmes <iain@helixcode.com>
* ename/e-address-western.c (e_address_western_parse): g_strconcat needs * ename/e-address-western.c (e_address_western_parse): g_strconcat
to be NULL terminated or it goes funny. needs to be NULL terminated or it goes funny.
Tue Sep 26 16:48:49 2000 Christopher James Lahey <clahey@helixcode.com> Tue Sep 26 16:48:49 2000 Christopher James Lahey <clahey@helixcode.com>

View File

@ -26,32 +26,6 @@
#include <glib.h> #include <glib.h>
#include <unicode.h> #include <unicode.h>
#if 0
static int etth_interesting[] = {
4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x00 - 0x0f */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */
1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* sp - / */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 2, 1, 2, /* 0 - ? */
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ - O */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, /* P - _ */
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ` - o */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, /* p - del */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x80 - 0x8f */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x90 - 0x9f */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xa0 - 0xaf */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xb0 - 0xbf */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xc0 - 0xcf */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xd0 - 0xdf */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 /* 0xf0 - 0xff */
};
#endif
#define ETTH_SPECIAL 1
#define ETTH_PUNCTUATION 2
#define ETTH_ESCAPED 3
#define ETTH_EOF 4
static char * static char *
check_size (char **buffer, int *buffer_size, char *out, int len) check_size (char **buffer, int *buffer_size, char *out, int len)
{ {
@ -127,9 +101,6 @@ char *
e_text_to_html (const char *input, unsigned int flags) e_text_to_html (const char *input, unsigned int flags)
{ {
const unsigned char *cur = input; const unsigned char *cur = input;
#if 0
const unsigned char *end;
#endif
char *buffer = NULL; char *buffer = NULL;
char *out = NULL; char *out = NULL;
int buffer_size = 0, col; int buffer_size = 0, col;
@ -148,10 +119,8 @@ e_text_to_html (const char *input, unsigned int flags)
unicode_char_t u; unicode_char_t u;
unicode_get_utf8 (cur, &u); unicode_get_utf8 (cur, &u);
if (unicode_isalpha (u) &&
if (u < 0) u = '_'; (flags & E_TEXT_TO_HTML_CONVERT_URLS)) {
if (unicode_isalpha (u) && (flags & E_TEXT_TO_HTML_CONVERT_URLS)) {
char *tmpurl = NULL, *refurl = NULL, *dispurl = NULL; char *tmpurl = NULL, *refurl = NULL, *dispurl = NULL;
if (!strncasecmp (cur, "http://", 7) || if (!strncasecmp (cur, "http://", 7) ||
@ -188,28 +157,13 @@ e_text_to_html (const char *input, unsigned int flags)
} }
unicode_get_utf8 (cur, &u); unicode_get_utf8 (cur, &u);
if (u < 0) u = '_';
} }
if (u == (unicode_char_t)-1) {
#if 0 /* Sigh. Someone sent undeclared 8-bit data.
/* Skip until we need to care. */ * Assume it's iso-8859-1.
end = cur; */
while (!etth_interesting[*end] || u = *cur;
(etth_interesting[*end] == ETTH_PUNCTUATION && }
!(flags & E_TEXT_TO_HTML_CONVERT_URLS)))
end++;
out = check_size (&buffer, &buffer_size, out,
end - cur + 10);
memcpy (out, cur, end - cur);
out += end - cur;
col += end - cur;
if (!*end)
break;
cur = end;
#endif
out = check_size (&buffer, &buffer_size, out, 10); out = check_size (&buffer, &buffer_size, out, 10);