+2005-11-08 [colin] 1.9.100cvs4
+
+ * src/compose.c
+ * src/textview.c
+ * src/common/utils.c
+ * src/common/utils.h
+ Enhance the email parser
+
2005-11-08 [colin] 1.9.100cvs3
* src/procmime.c
( cvs diff -u -r 1.115.2.65 -r 1.115.2.66 src/main.c; ) > 1.9.100cvs1.patchset
( cvs diff -u -r 1.115.2.66 -r 1.115.2.67 src/main.c; ) > 1.9.100cvs2.patchset
( cvs diff -u -r 1.49.2.67 -r 1.49.2.68 src/procmime.c; ) > 1.9.100cvs3.patchset
+( cvs diff -u -r 1.382.2.192 -r 1.382.2.193 src/compose.c; cvs diff -u -r 1.96.2.83 -r 1.96.2.84 src/textview.c; cvs diff -u -r 1.36.2.47 -r 1.36.2.48 src/common/utils.c; cvs diff -u -r 1.20.2.26 -r 1.20.2.27 src/common/utils.h; ) > 1.9.100cvs4.patchset
MICRO_VERSION=100
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=3
+EXTRA_VERSION=4
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
/* get_uri_part() - retrieves a URI starting from scanpos.
Returns TRUE if succesful */
gboolean get_uri_part(const gchar *start, const gchar *scanpos,
- const gchar **bp, const gchar **ep)
+ const gchar **bp, const gchar **ep, gboolean hdr)
{
const gchar *ep_;
/* get_email_part() - retrieves an email address. Returns TRUE if succesful */
gboolean get_email_part(const gchar *start, const gchar *scanpos,
- const gchar **bp, const gchar **ep)
+ const gchar **bp, const gchar **ep, gboolean hdr)
{
/* more complex than the uri part because we need to scan back and forward starting from
* the scan position. */
g_return_val_if_fail(bp != NULL, FALSE);
g_return_val_if_fail(ep != NULL, FALSE);
+ if (hdr) {
+search_again:
+ /* go to the real start */
+ if (start[0] == ',')
+ start++;
+ if (start[0] == ';')
+ start++;
+ while (start[0] == ' ' || start[0] == '\t')
+ start++;
+
+ *bp = start;
+
+ /* find end (either , or ; or end of line) */
+ if (strstr(start, ",") && strstr(start, ";"))
+ *ep = strstr(start,",") < strstr(start, ";")
+ ? strstr(start, ",") : strstr(start, ";");
+ else if (strstr(start, ","))
+ *ep = strstr(start, ",");
+ else if (strstr(start, ";"))
+ *ep = strstr(start, ";");
+ else
+ *ep = start+strlen(start);
+
+ /* check there's still an @ in that, or search
+ * further if possible */
+ if (strstr(start, "@") && strstr(start, "@") < *ep)
+ return TRUE;
+ else if (*ep < start+strlen(start)) {
+ start = *ep;
+ goto search_again;
+ } else
+ return FALSE;
+ }
+
if (!dom_tab)
dom_tab = create_domain_tab();
g_return_val_if_fail(dom_tab, FALSE);
&& (((bp_ + 1) < ep_) && isalnum(*(bp_ + 1)))) {
/* hyphens are allowed, but only in
between alnums */
- } else if (!strchr(",;:=?./+<>!&\r\n\t", *bp_)) {
+ } else if (strchr(" \"'", *bp_)) {
/* but anything not being a punctiation
is ok */
} else {
bp_++;
+ /* scan forward (should start with an alnum) */
+ for (; *bp_ != '<' && isspace(*bp_) && *bp_ != '"'; bp_++)
+ ;
#undef PEEK_STACK
#undef PUSH_STACK
#undef POP_STACK
#undef IN_STACK
#undef FULL_STACK
- /* scan forward (should start with an alnum) */
- for (; *bp_ != '<' && isspace(*bp_) && *bp_ != '"'; bp_++)
- ;
- *ep = ep_;
*bp = bp_;
+ *ep = ep_;
return result;
}
void replace_returns (gchar *str);
gboolean get_uri_part(const gchar *start, const gchar *scanpos,
- const gchar **bp, const gchar **ep);
+ const gchar **bp, const gchar **ep, gboolean hdr);
gchar *make_uri_string(const gchar *bp, const gchar *ep);
gboolean get_email_part(const gchar *start, const gchar *scanpos,
- const gchar **bp, const gchar **ep);
+ const gchar **bp, const gchar **ep, gboolean hdr);
gchar *make_email_string(const gchar *bp, const gchar *ep);
gchar *make_http_string(const gchar *bp, const gchar *ep);
gchar *mailcap_get_command_for_type(const gchar *type);
gboolean (*parse) (const gchar *start,
const gchar *scanpos,
const gchar **bp_,
- const gchar **ep_);
+ const gchar **ep_,
+ gboolean hdr);
/* part to URI function */
gchar *(*build_uri) (const gchar *bp,
const gchar *ep);
bp = ep = 0;
if (scanpos) {
/* check if URI can be parsed */
- if (parser[last_index].parse(walk, scanpos, (const gchar **)&bp,(const gchar **)&ep)
+ if (parser[last_index].parse(walk, scanpos, (const gchar **)&bp,
+ (const gchar **)&ep, FALSE)
&& (size_t) (ep - bp - 1) > strlen(parser[last_index].needle)) {
walk = ep;
} else
static void textview_make_clickable_parts(TextView *textview,
const gchar *fg_tag,
const gchar *uri_tag,
- const gchar *linebuf)
+ const gchar *linebuf,
+ gboolean hdr)
{
GtkTextView *text = GTK_TEXT_VIEW(textview->text);
GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
gboolean (*parse) (const gchar *start,
const gchar *scanpos,
const gchar **bp_,
- const gchar **ep_);
+ const gchar **ep_,
+ gboolean hdr);
/* part to URI function */
gchar *(*build_uri) (const gchar *bp,
const gchar *ep);
if (scanpos) {
/* check if URI can be parsed */
- if (parser[last_index].parse(walk, scanpos, &bp, &ep)
+ if (parser[last_index].parse(walk, scanpos, &bp, &ep, hdr)
&& (size_t) (ep - bp - 1) > strlen(parser[last_index].needle)) {
ADD_TXT_POS(bp, ep, last_index);
walk = ep;
textview->is_in_signature = TRUE;
}
- textview_make_clickable_parts(textview, fg_color, "link", buf);
+ textview_make_clickable_parts(textview, fg_color, "link", buf, FALSE);
}
void textview_write_link(TextView *textview, const gchar *str,
(buffer, &iter, header->body, -1,
"header", "emphasis", NULL);
} else {
- textview_make_clickable_parts(textview, "header", "link",
- header->body);
+ gboolean hdr =
+ procheader_headername_equal(header->name, "From") ||
+ procheader_headername_equal(header->name, "To") ||
+ procheader_headername_equal(header->name, "Cc") ||
+ procheader_headername_equal(header->name, "Bcc");
+ textview_make_clickable_parts(textview, "header",
+ "link", header->body,
+ hdr);
}
gtk_text_buffer_get_end_iter (buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,