aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.ja8
-rw-r--r--libsylph/procheader.c4
-rw-r--r--libsylph/utils.c50
-rw-r--r--libsylph/utils.h5
5 files changed, 73 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a241109..9599ac69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-05-16
+
+ * libsylph/utils.[ch]:
+ extract_parenthesis_with_escape()
+ extract_quote_with_escape(): added.
+ * libsylph/procheader.c: procheader_get_fromname(): process
+ quoted-pair correctly.
+
2007-05-15
* libsylph/procmime.[ch]: procmime_get_encoding_for_str(): added.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 4c79739a..c58e4f06 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,11 @@
+2007-05-16
+
+ * libsylph/utils.[ch]:
+ extract_parenthesis_with_escape()
+ extract_quote_with_escape(): 追加。
+ * libsylph/procheader.c: procheader_get_fromname(): quoted-pair
+ を適切に扱うようにした。
+
2007-05-15
* libsylph/procmime.[ch]: procmime_get_encoding_for_str(): 追加。
diff --git a/libsylph/procheader.c b/libsylph/procheader.c
index 4d45dbe7..2c931e07 100644
--- a/libsylph/procheader.c
+++ b/libsylph/procheader.c
@@ -752,7 +752,7 @@ gchar *procheader_get_fromname(const gchar *str)
Xstrdup_a(tmp, str, return NULL);
if (*tmp == '\"') {
- extract_quote(tmp, '\"');
+ extract_quote_with_escape(tmp, '\"');
g_strstrip(tmp);
} else if (strchr(tmp, '<')) {
eliminate_parenthesis(tmp, '<', '>');
@@ -763,7 +763,7 @@ gchar *procheader_get_fromname(const gchar *str)
g_strstrip(tmp);
}
} else if (strchr(tmp, '(')) {
- extract_parenthesis(tmp, '(', ')');
+ extract_parenthesis_with_escape(tmp, '(', ')');
g_strstrip(tmp);
}
diff --git a/libsylph/utils.c b/libsylph/utils.c
index 1336d954..56e7fccd 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -652,6 +652,37 @@ void extract_parenthesis(gchar *str, gchar op, gchar cl)
*destp = '\0';
}
+void extract_parenthesis_with_escape(gchar *str, gchar op, gchar cl)
+{
+ register gchar *srcp, *destp;
+ gint in_brace;
+
+ srcp = destp = str;
+
+ while ((srcp = strchr(srcp, op))) {
+ if (destp > str)
+ *destp++ = ' ';
+ ++srcp;
+ //memmove(destp, srcp + 1, strlen(srcp));
+ in_brace = 1;
+ while (*srcp) {
+ if (*srcp == op)
+ in_brace++;
+ else if (*srcp == cl)
+ in_brace--;
+
+ if (in_brace == 0)
+ break;
+
+ if (*srcp == '\\' && *(srcp + 1) != '\0')
+ ++srcp;
+
+ *destp++ = *srcp++;
+ }
+ }
+ *destp = '\0';
+}
+
void extract_parenthesis_with_skip_quote(gchar *str, gchar quote_chr,
gchar op, gchar cl)
{
@@ -713,6 +744,25 @@ void extract_quote(gchar *str, gchar quote_chr)
}
}
+void extract_quote_with_escape(gchar *str, gchar quote_chr)
+{
+ register gchar *sp, *dp;
+
+ if ((sp = strchr(str, quote_chr))) {
+ dp = sp;
+ ++sp;
+ while (*sp) {
+ if (*sp == quote_chr)
+ break;
+ else if (*sp == '\\' && *(sp + 1) != '\0')
+ ++sp;
+
+ *dp++ = *sp++;
+ }
+ *dp = '\0';
+ }
+}
+
void eliminate_address_comment(gchar *str)
{
register gchar *srcp, *destp;
diff --git a/libsylph/utils.h b/libsylph/utils.h
index fe0b585b..d7f68b91 100644
--- a/libsylph/utils.h
+++ b/libsylph/utils.h
@@ -257,6 +257,9 @@ void eliminate_parenthesis (gchar *str,
void extract_parenthesis (gchar *str,
gchar op,
gchar cl);
+void extract_parenthesis_with_escape (gchar *str,
+ gchar op,
+ gchar cl);
void extract_parenthesis_with_skip_quote (gchar *str,
gchar quote_chr,
@@ -267,6 +270,8 @@ void eliminate_quote (gchar *str,
gchar quote_chr);
void extract_quote (gchar *str,
gchar quote_chr);
+void extract_quote_with_escape (gchar *str,
+ gchar quote_chr);
void eliminate_address_comment (gchar *str);
gchar *strchr_with_skip_quote (const gchar *str,
gint quote_chr,