Subversion Repositories prayer-err

Compare Revisions

Ignore whitespace Rev 5 → Rev 4

/trunk/debian/control
1,13 → 1,9
Source: prayer
Section: mail
Priority: optional
Maintainer: Magnus Holmgren <holmgren@debian.org>
Build-Depends: cdbs (>= 0.4.27-1), debhelper (>= 5), quilt,
libc-client2007-dev, libldap2-dev,
zlib1g-dev, libssl-dev (>= 0.9.6), libdb4.3-dev | libdb-dev,
Maintainer: Magnus Holmgren <magnus@kibibyte.se>
Build-Depends: cdbs (>= 0.4.27-1), debhelper (>= 5), quilt, libc-client-dev, zlib1g-dev, libssl-dev (>= 0.9.6), libdb4.3-dev | libdb-dev, libldap2-dev
Standards-Version: 3.7.2
Vcs-Svn: svn://svn.kibibyte.se/prayer/trunk
Vcs-Browser: http://svn.kibibyte.se/prayer
 
Package: prayer
Architecture: any
/trunk/debian/patches/hasnochildren_means_noinferiors.patch
0,0 → 1,12
--- prayer-1.0.18.orig/prayer/dirlist.c
+++ prayer-1.0.18/prayer/dirlist.c
@@ -172,7 +172,8 @@
dl->next = NIL;
dl->name = pool_strdup(callback.pool, name);
- dl->isdir = (attributes & LATT_NOINFERIORS) ? NIL : T;
+ dl->isdir = (attributes & (LATT_NOINFERIORS | LATT_HASNOCHILDREN)) ?
+ NIL : T;
/* Insertion sort algorithm */
/trunk/debian/patches/ipv6.patch
0,0 → 1,508
--- prayer-1.0.18.orig/prayer/config.c
+++ prayer-1.0.18/prayer/config.c
@@ -1650,7 +1650,7 @@
if (!config_parse_rest(&option))
error = T;
- else if ((s = (strchr(option, ':')))) {
+ else if ((s = (strrchr(option, ':')))) {
*s++ = '\0';
if (!config_parse_number(&port, s))
error = T;
--- prayer-1.0.18.orig/prayer/ipaddr.c
+++ prayer-1.0.18/prayer/ipaddr.c
@@ -32,11 +32,7 @@
BOOL ipaddr_copy(struct ipaddr * dst, struct ipaddr * src)
{
- dst->version = src->version;
- dst->addr[0] = src->addr[0];
- dst->addr[1] = src->addr[1];
- dst->addr[2] = src->addr[2];
- dst->addr[3] = src->addr[3];
+ memcpy(dst, src, sizeof(struct ipaddr));
return (T);
}
@@ -55,19 +51,7 @@
if (addr1->version != addr2->version)
return (NIL);
- if (addr1->addr[0] != addr2->addr[0])
- return (NIL);
-
- if (addr1->addr[1] != addr2->addr[1])
- return (NIL);
-
- if (addr1->addr[2] != addr2->addr[2])
- return (NIL);
-
- if (addr1->addr[3] != addr2->addr[3])
- return (NIL);
-
- return (T);
+ return (memcmp(&addr1->addr, &addr2->addr, addr1->version == 6 ? 16 : 4) == 0);
}
/* ====================================================================== */
@@ -81,8 +65,7 @@
{
static char buf[64];
- sprintf(buf, "%d.%d.%d.%d",
- addr->addr[0], addr->addr[1], addr->addr[2], addr->addr[3]);
+ os_inet_ntop(addr->addr, addr->version, buf, 64);
return (buf);
}
@@ -96,7 +79,7 @@
{
char *result;
- if ((result = os_gethostbyaddr(addr->addr)))
+ if ((result = os_gethostbyaddr(addr->addr, addr->version)))
return (result);
return (ipaddr_text(addr));
@@ -116,39 +99,10 @@
BOOL ipaddr_parse(struct ipaddr * addr, char *text)
{
- char *next;
-
if (text == NIL)
return (NIL);
- /* IPv4 only for the moment */
- addr->version = 4;
-
- /* Parse first number */
- if (!(next = strchr(text, '.')))
- return (NIL);
- addr->addr[0] = atoi(text);
- text = next + 1;
-
- /* Parse second number */
- if (!(next = strchr(text, '.')))
- return (NIL);
- addr->addr[1] = atoi(text);
- text = next + 1;
-
- /* Parse third number */
- if (!(next = strchr(text, '.')))
- return (NIL);
- addr->addr[2] = atoi(text);
- text = next + 1;
-
- /* Parse forth number */
- if ((next = strchr(text, '.')))
- return (NIL);
- addr->addr[3] = atoi(text);
-
- /* Looks good */
- return (T);
+ return (os_inet_pton(text, addr));
}
/* ====================================================================== */
@@ -157,56 +111,63 @@
*
* Compare IP address to text list of form:
* ipaddr:
- * text: Text string of form "131.111.0.0/16 : 192.168.0.0/24".
+ * text: Text string of form "131.111.0.0/16 : 192.168.0.0/24 : 2001:12cd:1::/48".
+ * (There has to be a space on either side of the colon for it to
+ * separate two networks)
*
* Returns: T if addr matches list.
************************************************************************/
BOOL ipaddr_compare_list(struct ipaddr * ipaddr, char *text)
{
- char *next, *s, *alloc;
+ char *next = NULL, *s, *alloc;
+ int i;
unsigned long bits, mask;
struct ipaddr parsed;
alloc = text = pool_strdup(NIL, text);
while (text && *text) {
- if ((next = strchr(text, ':')))
- *next++ = '\0';
+ s = text;
+ while ((s = strchr(s, ':'))) {
+ if (*(s - 1) == ' ' || *(s + 1) == ' ') {
+ *(next = s) = '\0';
+ next++;
+ }
+ s++;
+ }
text = string_trim_whitespace(text);
if ((s = strchr(text, '/'))) {
*s++ = '\0';
bits = atoi(s);
- } else
- bits = 32;
-
- if (bits > 32)
- bits = 32;
-
- /* Create mask with appropriate number of bits set */
- mask = 0;
- while (bits > 0) {
- mask >>= 1;
- mask |= 0x80000000;
- bits--;
}
+ else
+ bits = 128; /* Doesn't matter if it's too big */
if (ipaddr_parse(&parsed, text)) {
- unsigned long a1;
- unsigned long a2;
-
- a1 = ((ipaddr->addr[0] << 24) + (ipaddr->addr[1] << 16) +
- (ipaddr->addr[2] << 8) + (ipaddr->addr[3]));
-
- a2 = ((parsed.addr[0] << 24) + (parsed.addr[1] << 16) +
- (parsed.addr[2] << 8) + (parsed.addr[3]));
-
- if ((a1 & mask) == (a2 & mask)) {
- free(alloc);
- return (T);
- }
+ if (parsed.version != ipaddr->version) {
+ text = next; continue;
+ }
+
+ for (i = 0; i < (parsed.version == 6 ? 4 : 1); i++) {
+ if (bits == 0) mask = 0;
+ else if (bits < 32) {
+ mask = (-1) << (32 - bits);
+ bits = 0;
+ }
+ else {
+ mask = -1;
+ bits -= 32;
+ }
+
+ if ((parsed.addr[i] & mask) != (ipaddr->addr[i] & mask)) {
+ text = next; continue;
+ }
+ }
+ free(alloc);
+ return (T);
}
text = next;
}
@@ -225,11 +187,11 @@
void ipaddr_send_iostream(struct ipaddr *addr, struct iostream *stream)
{
+ int i;
ioputc(addr->version, stream);
- ioputc(addr->addr[0], stream);
- ioputc(addr->addr[1], stream);
- ioputc(addr->addr[2], stream);
- ioputc(addr->addr[3], stream);
+ for (i = 0; i < (addr->version == 6 ? 16 : 4); i++) {
+ ioputc(((char *)addr->addr)[i], stream);
+ }
}
/* ====================================================================== */
@@ -246,13 +208,13 @@
if ((c = iogetc(stream)) != EOF) {
addr->version = (unsigned char) c;
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < (addr->version == 6 ? 16 : 4); i++) {
if ((c = iogetc(stream)) == EOF) {
rc = NIL;
break;
}
- addr->addr[i] = (unsigned char) c;
+ ((char *)addr->addr)[i] = (unsigned char) c;
}
}
@@ -279,9 +241,14 @@
ipaddr_set(struct ipaddr *ipaddr, unsigned long version,
unsigned char *addr)
{
- if (version != 4)
- log_fatal("ipaddr_set(): IPv4 only supported at the moment!");
+ if (version != 4 && version != 6)
+ log_fatal("ipaddr_set(): IPv4 and IPv6 only supported!");
+
+ ipaddr->version = version;
+ memcpy(ipaddr->addr, addr, version == 6 ? 16 : 4);
+ if (ipaddr->addr[0] == 0 && ipaddr->addr[1] == 0 && ipaddr->addr[2] == 0xffff) {
+ ipaddr->addr[0] = ipaddr->addr[3];
+ ipaddr->version = 4;
+ }
- ipaddr->version = 4;
- memcpy(ipaddr->addr, addr, 4);
}
--- prayer-1.0.18.orig/prayer/ipaddr.h
+++ prayer-1.0.18/prayer/ipaddr.h
@@ -8,7 +8,7 @@
struct ipaddr {
unsigned long version;
- unsigned char addr[4];
+ unsigned long addr[4];
};
struct ipaddr *ipaddr_create(struct pool *pool);
--- prayer-1.0.18.orig/prayer/os.h
+++ prayer-1.0.18/prayer/os.h
@@ -24,7 +24,11 @@
int os_socket_nonblocking(int sockfd);
-char *os_gethostbyaddr(void *addr);
+char *os_gethostbyaddr(void *addr, unsigned int version);
+
+int os_inet_ntop(void *addr, unsigned long version, char *buf, unsigned long buflen);
+
+int os_inet_pton(char *str, struct ipaddr *addr);
void os_child_reaper();
--- prayer-1.0.18.orig/prayer/os_linux.c
+++ prayer-1.0.18/prayer/os_linux.c
@@ -13,14 +13,11 @@
#include <sys/un.h>
#include <sys/resource.h>
#include <netinet/in.h>
-#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <signal.h>
#include <netdb.h>
#include <sys/file.h>
-#include <openssl/rand.h>
-
/* ====================================================================== */
BOOL os_socketpair(int *sockfd)
@@ -63,33 +60,28 @@
int os_connect_inet_socket(char *host, unsigned long port)
{
- struct hostent *hostent;
- struct sockaddr_in serv_addr;
+ struct addrinfo *first_ai, *ai;
+ char port_str[12];
int sockfd;
- /* Open the socket */
- if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- return (-1);
-
- /* Set up the socket */
- bzero((char *) &serv_addr, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(port);
-
- if ((hostent = gethostbyname(host)) == NIL) {
- close(sockfd);
- return (-1);
- }
- bcopy(hostent->h_addr, (char *) &serv_addr.sin_addr,
- hostent->h_length);
-
- if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))
- < 0) {
- close(sockfd);
- return (-1);
- }
-
- return (sockfd);
+ sprintf(port_str, "%lu", port);
+ if (getaddrinfo(host, port_str, NULL, &first_ai)) {
+ return (-1);
+ }
+ for (ai = first_ai; ai->ai_next; ai = ai->ai_next) {
+ /* Open the socket */
+ if ((sockfd = socket(ai->ai_family, SOCK_STREAM, 0)) < 0) {
+ break;
+ }
+ if (connect(sockfd, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) < 0) {
+ close(sockfd);
+ break;
+ }
+ freeaddrinfo(first_ai);
+ return (sockfd);
+ }
+ freeaddrinfo(first_ai);
+ return (-1);
}
/* ====================================================================== */
@@ -150,9 +141,39 @@
int os_bind_inet_socket(unsigned long port, char *interface)
{
int i, sockfd;
- struct sockaddr_in serv_addr;
+ struct sockaddr_storage serv_addr;
+ struct addrinfo *ai;
+
+ bzero((char *) &serv_addr, sizeof(serv_addr));
- if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ if (interface) {
+ if (getaddrinfo(interface, NULL, NULL, &ai)) {
+ log_panic
+ ("[os_bind_inet_socket()] Failed to lookup hostname: %s",
+ interface);
+ return -1;
+ }
+#if 0 /* Use the first interface address; don't panic if both IPv6
+ and IPv4 addresses are returned. */
+ if (hostent->h_addr_list[1]) {
+ log_panic
+ ("[os_bind_inet_socket()] Ambiguous interface name: %s",
+ interface);
+ return (-1);
+ }
+#endif
+ memcpy(&serv_addr, ai->ai_addr, ai->ai_addrlen);
+ freeaddrinfo(ai);
+ }
+ else {
+ serv_addr.ss_family = AF_INET6;
+ ((struct sockaddr_in6*)&serv_addr)->sin6_addr = in6addr_any;
+ }
+ /* This isn't formally correct, but *in fact*, sin6_port is at the
+ same place as sin_port, so it works. */
+ ((struct sockaddr_in6*)&serv_addr)->sin6_port = htons(port);
+
+ if ((sockfd = socket(serv_addr.ss_family, SOCK_STREAM, 0)) < 0) {
log_panic("[os_bind_inet_socket()] socket() failed, %s",
strerror(errno));
return (-1);
@@ -168,41 +189,6 @@
return (-1);
}
- bzero((char *) &serv_addr, sizeof(serv_addr));
- serv_addr.sin_family = AF_INET;
- serv_addr.sin_port = htons(port);
- serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
-
- /* Calculate serv_addr for specific interface to bind to */
- if (interface) {
- struct hostent *hostent;
- struct in_addr *s;
-
- if (!(hostent = gethostbyname(interface))) {
- log_panic
- ("[os_bind_inet_socket()] Failed to lookup hostname: %s",
- interface);
-
- return (-1);
- }
-
- if (hostent->h_addr_list[1]) {
- log_panic
- ("[os_bind_inet_socket()] Ambiguous interface name: %s",
- interface);
- return (-1);
- }
-
- if (!(s = ((struct in_addr *)hostent->h_addr_list[0]))) {
- log_panic("[os_bind_inet_socket()] Invalid interface name: %s",
- interface);
- return (-1);
- }
-
- /* s has four bytes in network byte order */
- memcpy(&serv_addr.sin_addr.s_addr, s, sizeof(struct in_addr));
- }
-
/* bind() as Internet domain socket */
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) <
0) {
@@ -255,8 +242,8 @@
int os_accept_inet(int sockfd, struct ipaddr *ipaddr)
{
- struct sockaddr_in addr;
- socklen_t len = (socklen_t) sizeof(struct sockaddr_in);
+ struct sockaddr_storage addr;
+ socklen_t len = (socklen_t) sizeof(addr);
int newsockfd;
do {
@@ -271,8 +258,12 @@
return (-1);
}
- if (ipaddr)
- ipaddr_set(ipaddr, 4, (unsigned char *) &addr.sin_addr);
+ if (ipaddr) {
+ if (addr.ss_family == AF_INET6)
+ ipaddr_set(ipaddr, 6, (unsigned char *)&((struct sockaddr_in6*)&addr)->sin6_addr);
+ else
+ ipaddr_set(ipaddr, 4, (unsigned char *)&((struct sockaddr_in*)&addr)->sin_addr);
+ }
/* Set close on exec so subprocesses can't interfere */
if (fcntl(newsockfd, F_SETFD, FD_CLOEXEC) < 0) {
@@ -322,9 +313,14 @@
/* Convert IPv4 address into text form */
-char *os_gethostbyaddr(void *opaque)
+char *os_gethostbyaddr(void *opaque, unsigned int version)
{
- struct hostent *hostent = gethostbyaddr(opaque, 4, AF_INET);
+ struct hostent *hostent;
+
+ if (version == 6)
+ hostent = gethostbyaddr(opaque, 16, AF_INET6);
+ else
+ hostent = gethostbyaddr(opaque, 4, AF_INET);
if (hostent && hostent->h_name && hostent->h_name[0])
return (hostent->h_name);
@@ -332,6 +328,32 @@
return (NIL);
}
+int os_inet_ntop(void *addr, unsigned long version, char *buf, unsigned long buflen) {
+ if (version == 6) {
+ if (inet_ntop(AF_INET6, addr, buf, buflen))
+ return (T);
+ }
+ else {
+ if (inet_ntop(AF_INET, addr, buf, buflen))
+ return (T);
+ }
+ return (NIL);
+}
+
+int os_inet_pton(char *str, struct ipaddr *addr) {
+ unsigned char buf[16];
+
+ if (inet_pton(AF_INET6, str, buf)) {
+ ipaddr_set(addr, 6, buf);
+ return (T);
+ }
+ else if (inet_pton(AF_INET, str, buf)) {
+ ipaddr_set(addr, 4, buf);
+ return (T);
+ }
+ return (NIL);
+}
+
/* ====================================================================== */
/* Trivial SIG_CLD handler to prevent zombies from hanging around */
/trunk/debian/patches/includes.patch
1,5 → 1,7
--- prayer-1.1.0.orig/prayer/prayer_session.h
+++ prayer-1.1.0/prayer/prayer_session.h
Index: prayer-1.0.18/prayer/prayer_session.h
===================================================================
--- prayer-1.0.18.orig/prayer/prayer_session.h 2007-03-10 18:50:09.676882377 +0100
+++ prayer-1.0.18/prayer/prayer_session.h 2007-03-10 18:50:11.007049496 +0100
@@ -27,7 +27,7 @@
extern int errno; /* just in case */
9,8 → 11,10
#define PRAYER_FULL_HDRS
#include "prayer_shared.h"
--- prayer-1.1.0.orig/prayer/cdb.c
+++ prayer-1.1.0/prayer/cdb.c
Index: prayer-1.0.18/prayer/cdb.c
===================================================================
--- prayer-1.0.18.orig/prayer/cdb.c 2007-03-10 18:51:20.845827434 +0100
+++ prayer-1.0.18/prayer/cdb.c 2007-03-10 18:51:25.766446163 +0100
@@ -63,7 +63,7 @@
#include <unistd.h>
#include <sys/stat.h>
/trunk/debian/patches/session_unix_bugs.patch
0,0 → 1,20
--- prayer-1.0.18.orig/prayer/session_unix.c
+++ prayer-1.0.18/prayer/session_unix.c
@@ -56,7 +56,7 @@
}
if (config->fix_client_ipaddr
- && ipaddr_compare(session->ipaddr, &remote)) {
+ && !ipaddr_compare(session->ipaddr, &remote)) {
struct buffer *b = request->write_buffer;
html_common_start(config, b, "Security Alert");
@@ -69,7 +69,7 @@
response_send(request);
log_misc
("HTTP Request from invalid IP address %s to running session %s",
- &remote, session->url_prefix_asession);
+ ipaddr_text(&remote), session->url_prefix_asession);
return;
}
/trunk/debian/patches/utf8.patch
0,0 → 1,1507
This patch adds support for UTF-8 and modified UTF-7. Functions are in
the new utf8.c. The patch adds calls to utf8_to_imaputf7() or
utf8_from_imaputf7() wherever a folder name is handled in the code. In
addition, it changes prayer to use UTF-8 in all HTML output as well as
in composition of messages.
Index: prayer-1.0.18/prayer/Makefile
===================================================================
--- prayer-1.0.18.orig/prayer/Makefile 2007-03-10 19:39:29.563948453 +0100
+++ prayer-1.0.18/prayer/Makefile 2007-03-10 19:39:30.294042473 +0100
@@ -127,7 +127,7 @@ SESSION_SUPPORT_OBJS = \
abook.o lookup.o role.o dictionary.o \
options.o rfc1522.o banner.o favourite.o wrap.o portlist.o \
account.o account_msshell.o account_sieve.o account_support.o \
- sieve.o filter.o checksum.o
+ sieve.o filter.o checksum.o utf8.o
ifeq ($(strip $(SESSION_NEEDS_DB)), true)
SESSION_SUPPORT_OBJS += mydb_db3.o
Index: prayer-1.0.18/prayer/cmd_change.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_change.c 2007-03-10 19:38:53.659325192 +0100
+++ prayer-1.0.18/prayer/cmd_change.c 2007-03-10 19:39:30.344048912 +0100
@@ -16,7 +16,7 @@ void cmd_change(struct session *session)
if (request->method == POST) {
request_decode_post(request);
- if (!(name = assoc_lookup(request->form, "folder"))) {
+ if (!(name = utf8_to_imaputf7(request->pool, assoc_lookup(request->form, "folder")))) {
session_redirect(session, request, "error");
return;
}
@@ -30,7 +30,8 @@ void cmd_change(struct session *session)
}
if (!session_streams_change(session, name)) {
- session_message(session, "Unable to switch to folder: %s", name);
+ session_message(session, "Unable to switch to folder: %s",
+ utf8_from_imaputf7(request->pool, name));
session_redirect(session, request, "restart");
return;
}
@@ -47,7 +48,7 @@ void cmd_change(struct session *session)
}
session_message(session, "Switched to mailbox: %s",
- session->foldername);
+ utf8_from_imaputf7(request->pool, session->foldername));
session_log(session, "[cmd_change] Switched to mailbox: %s",
session->foldername);
Index: prayer-1.0.18/prayer/cmd_compose.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_compose.c 2007-03-10 19:38:53.719332917 +0100
+++ prayer-1.0.18/prayer/cmd_compose.c 2007-03-10 19:39:30.384054064 +0100
@@ -244,7 +244,7 @@ static BOOL cmd_compose_generate_postpon
strlen(string), string, NIL);
string =
- string_prune(request->pool, string, config->list_addr_maxlen);
+ utf8_prune(request->pool, string, config->list_addr_maxlen);
bputs(b, "<td>" CRLF);
html_quote_string(b, string);
@@ -267,7 +267,7 @@ static BOOL cmd_compose_generate_postpon
rfc1522_decode(pool_alloc(request->pool, strlen(string)),
strlen(string), string, NIL);
- string = string_prune(request->pool, string,
+ string = utf8_prune(request->pool, string,
config->list_subject_maxlen);
} else
string = "(No subject)";
Index: prayer-1.0.18/prayer/cmd_copy.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_copy.c 2007-03-10 19:38:53.769339356 +0100
+++ prayer-1.0.18/prayer/cmd_copy.c 2007-03-10 19:39:30.404056640 +0100
@@ -95,7 +95,7 @@ generate_directory_line(struct session *
html_session_bprintf(session, b,
"<td><a href=\"", "\">" CRLF, "copy?cwd=%s",
name);
- html_quote_string(b, dir);
+ html_quote_string(b, utf8_from_imaputf7(pool, dir));
bprintf(b, "</a></td>" CRLF);
bputs(b, "</tr>" CRLF);
@@ -127,7 +127,7 @@ generate_favourite_folder_line(struct se
html_session_bprintf(session, b,
"<td><a href=\"", "\">" CRLF, "copy_msg/%s",
name);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bprintf(b, "</a></td>" CRLF);
bputs(b, "</tr>" CRLF);
@@ -159,7 +159,7 @@ generate_folder_line(struct session *ses
html_session_bprintf(session, b,
"<td><a href=\"", "\">" CRLF, "copy_msg/%s",
name);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bprintf(b, "</a></td>" CRLF);
bprintf(b, "</tr>" CRLF);
@@ -209,8 +209,8 @@ html_folderlist(struct session *session,
bputs(b, "<tr>");
bputs(b, "<td>");
bputs(b, "<table><tr><td>" CRLF);
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "submit", "Apply");
bputs(b, "</td></tr></table>" CRLF);
bputs(b, "<td align=\"right\"><table><tr><td>" CRLF);
Index: prayer-1.0.18/prayer/cmd_copy_msg.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_copy_msg.c 2007-03-10 19:38:53.829347082 +0100
+++ prayer-1.0.18/prayer/cmd_copy_msg.c 2007-03-10 19:39:30.484066944 +0100
@@ -125,12 +125,13 @@ void cmd_copy_msg(struct session *sessio
/* Keep current message */
if (count > 1) {
session_message(session, "Copied %lu messages to %s", count,
- mailbox);
+ utf8_from_imaputf7(request->pool, mailbox));
session_log(session,
"[cmd_copy_msg] Copied %lu messages to %s", count,
mailbox);
} else if (count == 1) {
- session_message(session, "Copied 1 message to %s", mailbox);
+ session_message(session, "Copied 1 message to %s",
+ utf8_from_imaputf7(request->pool, mailbox));
session_log(session, "[cmd_copy_msg] Copied 1 message to %s",
mailbox);
} else {
@@ -152,9 +153,8 @@ void cmd_copy_msg(struct session *sessio
next = msgmap_value(zm, zm_offset + 1);
else {
/* No next message */
- session_message(session,
- "Copied message %lu to \"%s\", no more messages",
- msgno, mailbox);
+ session_message(session, "Copied message %lu to \"%s\", no more messages",
+ msgno, utf8_from_imaputf7(request->pool, mailbox));
session_log(session, "[cmd_copy_msg] Copied message %lu to %s",
msgno, mailbox);
session->current = msgno;
@@ -162,9 +162,8 @@ void cmd_copy_msg(struct session *sessio
return;
}
- session_message(session,
- "Copied message %lu to \"%s\", displaying %lu out of %lu",
- msgno, mailbox, next, zm->nmsgs);
+ session_message(session, "Copied message %lu to \"%s\", displaying %lu out of %lu",
+ msgno, utf8_from_imaputf7(request->pool, mailbox), next, zm->nmsgs);
session_log(session, "[cmd_copy_msg] Copied message %lu to %s",
msgno, mailbox);
Index: prayer-1.0.18/prayer/cmd_create.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_create.c 2007-03-10 19:38:53.919358672 +0100
+++ prayer-1.0.18/prayer/cmd_create.c 2007-03-10 19:39:30.554075959 +0100
@@ -21,7 +21,8 @@ void cmd_create(struct session *session)
request_decode_get(request);
- if ((mailbox = assoc_lookup(request->form, "name")) == NIL) {
+ if ((mailbox = utf8_to_imaputf7(request->pool,
+ assoc_lookup(request->form, "name"))) == NIL) {
session_redirect(session, request, "error");
return;
}
@@ -58,12 +59,13 @@ void cmd_create(struct session *session)
if (ml_have_error()) {
session_message(session,
"Failed to create directory: %s - %s",
- path, ml_errmsg());
+ utf8_from_imaputf7(request->pool, path), ml_errmsg());
session_log(session,
"[cmd_create] Failed to create directory: %s",
path);
} else {
- session_message(session, "Created directory: %s", path);
+ session_message(session, "Created directory: %s",
+ utf8_from_imaputf7(request->pool, path));
session_log(session,
"[cmd_create] Created directory: %s", path);
dircache_add(session->dircache, path, T);
@@ -72,12 +74,13 @@ void cmd_create(struct session *session)
if (ml_have_error()) {
session_message(session,
"Failed to create mailbox: %s - %s",
- path, ml_errmsg());
+ utf8_from_imaputf7(request->pool, path), ml_errmsg());
session_log(session,
"[cmd_create] Failed to create mailbox: %s",
path);
} else {
- session_message(session, "Created mailbox: %s", path);
+ session_message(session, "Created mailbox: %s",
+ utf8_from_imaputf7(request->pool, path));
session_log(session, "[cmd_create] Created mailbox: %s",
path);
dircache_add(session->dircache, path, NIL);
Index: prayer-1.0.18/prayer/cmd_dir_check.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_dir_check.c 2007-03-10 19:38:53.979366397 +0100
+++ prayer-1.0.18/prayer/cmd_dir_check.c 2007-03-10 19:39:30.584079823 +0100
@@ -43,7 +43,7 @@ void cmd_dir_check(struct session *sessi
session_message(session,
"Refreshed directory cache for directory \"%s\" at %s",
- session->cwd, current_time());
+ utf8_from_imaputf7(request->pool, session->cwd), current_time());
dircache_invalidate(session, session->cwd);
if (request->argc >= 2)
Index: prayer-1.0.18/prayer/cmd_display.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_display.c 2007-03-10 19:38:54.049375411 +0100
+++ prayer-1.0.18/prayer/cmd_display.c 2007-03-10 19:39:30.644087551 +0100
@@ -567,9 +567,11 @@ show_textpart(struct session *session, M
struct request *request = session->request;
struct buffer *b = request->write_buffer;
char *init_msg, *decode_msg;
+ char *charset = "ISO-8859-1";
unsigned long len;
BODY *body = NIL;
BOOL show_html = NIL;
+ PARAMETER *parameter;
if (!(body = ml_body(session, stream, msgno, section)))
return(NIL);
@@ -580,6 +582,13 @@ show_textpart(struct session *session, M
return(NIL);
}
+ for (parameter = body->parameter; parameter; parameter = parameter->next) {
+ if (strcasecmp(parameter->attribute, "charset") == 0) {
+ charset = parameter->value;
+ break;
+ }
+ }
+
if (!(init_msg = ml_fetchbody(session, stream, msgno, section, &len)))
return(NIL);
@@ -637,10 +646,10 @@ show_textpart(struct session *session, M
if (show_html) {
if (decode_msg == init_msg)
decode_msg = strdup(init_msg);
- html_secure(session, b, decode_msg);
+ html_secure(session, b, utf8_from_string(request->pool, charset, decode_msg, len));
} else {
bprintf(b, "<pre>" CRLF);
- wrap_line_html(session, b, decode_msg, 80);
+ wrap_line_html(session, b, utf8_from_string(request->pool, charset, decode_msg, len), 80);
bprintf(b, "</pre>" CRLF);
}
Index: prayer-1.0.18/prayer/cmd_favourites.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_favourites.c 2007-03-10 19:38:54.109383138 +0100
+++ prayer-1.0.18/prayer/cmd_favourites.c 2007-03-10 19:39:30.664090126 +0100
@@ -104,7 +104,7 @@ generate_directory_line(struct session *
html_session_bprintf(session, b, "<a href=\"", "\">" CRLF,
"favourites?cwd=%s", name);
- html_quote_string(b, dir);
+ html_quote_string(b, utf8_from_imaputf7(pool, dir));
bprintf(b, "</a></td>" CRLF);
bputs(b, "<td>&nbsp;</td>" CRLF);
bputs(b, "<td>&nbsp;</td>" CRLF);
@@ -134,7 +134,7 @@ generate_favourite_folder_line(struct se
bputs(b, "</td>" CRLF);
bputs(b, "<td nowrap>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bputs(b, "</td>" CRLF);
html_textlink_mailbox_table(session, b, "unsubscribe", name,
@@ -170,7 +170,7 @@ generate_folder_line(struct session *ses
bputs(b, "</td>" CRLF);
bprintf(b, "<td nowrap>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bprintf(b, "</td>" CRLF);
html_textlink_mailbox_table(session, b, "subscribe", name,
@@ -208,8 +208,8 @@ html_folderlist(struct session *session,
bputs(b, "<tr>");
bputs(b, "<td>");
bputs(b, "<table><tr><td>" CRLF);
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "submit", "Apply");
bputs(b, "</td></tr></table>" CRLF);
bputs(b, "</td>" CRLF);
Index: prayer-1.0.18/prayer/cmd_filter_select.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_filter_select.c 2007-03-10 19:38:54.159389577 +0100
+++ prayer-1.0.18/prayer/cmd_filter_select.c 2007-03-10 19:39:30.694093991 +0100
@@ -68,7 +68,7 @@ generate_directory_line(struct session *
html_session_bprintf(session, b, "<td><a href=\"", "\">" CRLF,
"filter_select?cwd=%s", name);
- html_quote_string(b, dir);
+ html_quote_string(b, utf8_from_imaputf7(pool, dir));
bprintf(b, "</a></td>" CRLF);
bputs(b, "</tr>" CRLF);
@@ -93,7 +93,7 @@ generate_favourite_folder_line(struct se
bputs(b, "</td>" CRLF);
bputs(b, "<td>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bputs(b, "</td>" CRLF);
html_textlink_mailbox_table(session, b, "filter_mbox/copy", name,
@@ -124,7 +124,7 @@ generate_folder_line(struct session *ses
bputs(b, "</td>" CRLF);
bputs(b, "<td>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bputs(b, "</td>" CRLF);
html_textlink_mailbox_table(session, b, "filter_mbox/copy", name,
@@ -159,8 +159,8 @@ html_folderlist(struct session *session,
/* Change directory form, including back button */
html_form_start(session, b, "GET", "filter_select");
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "sub_apply", "Apply");
html_form_submit(b, "sub_cancel", "Cancel");
html_form_end(b);
Index: prayer-1.0.18/prayer/cmd_folders.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_folders.c 2007-03-10 19:38:54.249401166 +0100
+++ prayer-1.0.18/prayer/cmd_folders.c 2007-03-10 19:39:30.734099143 +0100
@@ -95,7 +95,7 @@ generate_directory_line(struct session *
html_session_bprintf(session, b, "<td><a href=\"", "\">" CRLF,
"folders?cwd=%s", name);
- html_quote_string(b, dir);
+ html_quote_string(b, utf8_from_imaputf7(pool, dir));
bprintf(b, "</a></td>" CRLF);
html_textlink_mailbox_table(session, b, "rename", name, "Rename");
@@ -127,7 +127,7 @@ generate_folder_line(struct session *ses
html_session_bprintf(session, b, "<td nowrap><a href=\"", "\">" CRLF,
"change/%s", name);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bprintf(b, "</a></td>" CRLF);
if (strcmp(name, "INBOX") != 0) {
@@ -165,8 +165,8 @@ html_folderlist(struct session *session,
else
bputs(b, "<tr>");
bputs(b, "<td><table><tr><td>" CRLF);
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "submit", "Apply");
bputs(b, "</td></tr></table></td>" CRLF);
bputs(b, "<td align=\"right\"><table><tr>" CRLF);
@@ -267,7 +267,7 @@ void cmd_folders(struct session *session
request_decode_get(request);
h = request->form;
- if ((s = assoc_lookup(h, "cwd"))) {
+ if ((s = utf8_to_imaputf7(request->pool, assoc_lookup(h, "cwd")))) {
string_canon_decode(s);
if (string_filename_valid(s))
@@ -277,7 +277,7 @@ void cmd_folders(struct session *session
"Path contained illegal characters");
}
- if ((s = assoc_lookup(h, "filter"))
+ if ((s = utf8_to_imaputf7(request->pool, assoc_lookup(h, "filter")))
&& (strcmp(s, session->dir_filter) != 0))
string_strdup(&session->dir_filter, s);
}
Index: prayer-1.0.18/prayer/cmd_forward1.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_forward1.c 2007-03-10 19:38:54.309408891 +0100
+++ prayer-1.0.18/prayer/cmd_forward1.c 2007-03-10 19:39:30.744100430 +0100
@@ -157,6 +157,8 @@ add_text(struct session *session,
char *init_msg, *decode_msg, *type;
BODY *body = NIL;
char *section = "1";
+ PARAMETER *parameter;
+ char *charset = "ISO-8859-1";
if (!(text = ml_fetch_header(session, stream, msgno,
NIL, hdrslist, &len, 0)))
@@ -204,6 +206,13 @@ add_text(struct session *session,
} else
section = "1";
+ for (parameter = body->parameter; parameter; parameter = parameter->next) {
+ if (strcasecmp(parameter->attribute, "charset") == 0) {
+ charset = parameter->value;
+ break;
+ }
+ }
+
if (!(init_msg = ml_fetchbody(session, stream, msgno, section, &len)))
return (NIL);
Index: prayer-1.0.18/prayer/cmd_list.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_list.c 2007-03-10 19:38:54.379417906 +0100
+++ prayer-1.0.18/prayer/cmd_list.c 2007-03-10 19:39:30.794106870 +0100
@@ -143,7 +143,7 @@ cmd_list_toolbar_hdr(struct session *ses
bputs(b, "</tr></table></td>" CRLF);
bputs(b, "<td width=\"33%\" align=\"center\"><strong>\"");
- html_quote_string(b, session->foldername);
+ html_quote_string(b, utf8_from_imaputf7(session->request->pool, session->foldername));
bputs(b, "\" with ");
bprintf(b, "%lu%s %s" CRLF, count, marked, messages);
bputs(b, "</strong></td>" CRLF);
@@ -378,7 +378,7 @@ cmd_list_msg(struct session *session,
(char *) rfc1522_decode(pool_alloc(request->pool, strlen(string)),
strlen(string), string, NIL);
- string = string_prune(request->pool, string, config->list_addr_maxlen);
+ string = utf8_prune(request->pool, string, config->list_addr_maxlen);
if (use_to)
string = pool_strcat(request->pool, "To: ", string);
@@ -400,7 +400,7 @@ cmd_list_msg(struct session *session,
rfc1522_decode(pool_alloc(request->pool, strlen(string)),
strlen(string), string, NIL);
- string = string_prune(request->pool, string,
+ string = utf8_prune(request->pool, string,
config->list_subject_maxlen);
} else
string = "(No subject)";
Index: prayer-1.0.18/prayer/cmd_preferred.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_preferred.c 2007-03-10 19:38:54.429424344 +0100
+++ prayer-1.0.18/prayer/cmd_preferred.c 2007-03-10 19:39:30.824110733 +0100
@@ -22,7 +22,8 @@ void cmd_preferred(struct session *sessi
if (string_filename_valid(name)) {
favourite_preferred(fl, name);
options->save = T;
- session_message(session, "Making %s preferred folder", name);
+ session_message(session, "Making %s preferred folder",
+ utf8_from_imaputf7(request->pool, name));
} else
session_message(session,
"String contained illegal characters");
Index: prayer-1.0.18/prayer/cmd_rename.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_rename.c 2007-03-10 19:38:54.499433358 +0100
+++ prayer-1.0.18/prayer/cmd_rename.c 2007-03-10 19:39:30.844113310 +0100
@@ -63,7 +63,7 @@ generate_directory_line(struct session *
bprintf(b, "</a></td>" CRLF);
html_session_bprintf(session, b, "<td><a href=\"", "\">" CRLF,
"rename?cwd=%s", name);
- html_quote_string(b, dir);
+ html_quote_string(b, utf8_from_imaputf7(pool, dir));
bprintf(b, "</a></td></tr>" CRLF);
}
@@ -84,7 +84,7 @@ generate_folder_line(struct session *ses
html_icon(session, b, "dir.gif", "[mailbox]");
bputs(b, "</a></td>" CRLF);
bputs(b, "<td><a>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bputs(b, "</a></td></tr>" CRLF);
}
@@ -107,7 +107,7 @@ rename_html_folderlist(struct session *s
if (session->rename_foldername)
bprintf(b,
"<h2 align=\"center\">Rename folder %s to ...</h2>" CRLF,
- session->rename_foldername);
+ utf8_from_imaputf7(pool, session->rename_foldername));
/* Change directory form, including back button */
html_form_start(session, b, "GET", "rename");
@@ -118,8 +118,8 @@ rename_html_folderlist(struct session *s
else
bputs(b, "<tr>");
bputs(b, "<td>" CRLF);
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "submit", "Apply");
bputs(b, "</td></tr></table>" CRLF);
html_form_end(b);
Index: prayer-1.0.18/prayer/cmd_rename_item.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_rename_item.c 2007-03-10 19:38:54.569442372 +0100
+++ prayer-1.0.18/prayer/cmd_rename_item.c 2007-03-10 19:39:30.864115885 +0100
@@ -29,7 +29,7 @@ void cmd_rename_item(struct session *ses
}
if (!(session->rename_foldername &&
- (newname = assoc_lookup(request->form, "name")))) {
+ (newname = utf8_to_imaputf7(pool, assoc_lookup(request->form, "name"))))) {
session_redirect(session, request, "folders");
return;
}
@@ -70,11 +70,13 @@ void cmd_rename_item(struct session *ses
if (ml_have_error()) {
session_message(session,
"Failed to rename mailbox: %s - %s",
- session->rename_foldername, ml_errmsg());
+ utf8_from_imaputf7(pool, session->rename_foldername),
+ ml_errmsg());
} else {
session_message(session,
"Renamed mailbox %s to be %s",
- session->rename_foldername, newname);
+ utf8_from_imaputf7(pool, session->rename_foldername),
+ newname);
dircache_rename(session->dircache, session->rename_foldername,
newname);
}
Index: prayer-1.0.18/prayer/cmd_reply2.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_reply2.c 2007-03-10 19:38:54.619448812 +0100
+++ prayer-1.0.18/prayer/cmd_reply2.c 2007-03-10 19:39:30.894119749 +0100
@@ -51,6 +51,8 @@ add_text(struct session *session, struct
char *init_msg, *decode_msg, *type;
unsigned long len;
char *text, *s;
+ PARAMETER *parameter;
+ char *charset = "ISO-8859-1";
if ((body = ml_body(session, stream, msgno, "1")) == NIL)
return(NIL);
@@ -91,6 +93,13 @@ add_text(struct session *session, struct
return(T);
}
+ for (parameter = body->parameter; parameter; parameter = parameter->next) {
+ if (strcasecmp(parameter->attribute, "charset") == 0) {
+ charset = parameter->value;
+ break;
+ }
+ }
+
/* Got a valid text section to display */
if (!(init_msg=ml_fetchbody(session, stream, msgno, section, &len)))
return(NIL);
@@ -133,11 +142,11 @@ add_text(struct session *session, struct
struct buffer *b = buffer_create(pool, 8192);
if (decode_msg == init_msg)
decode_msg = strdup(init_msg);
- html_secure_strip_all(b, decode_msg);
+ html_secure_strip_all(b, utf8_from_string(pool, charset, decode_msg, len));
text = buffer_fetch(b, 0, buffer_size(b), NIL);
} else
- text = decode_msg;
+ text = utf8_from_string(pool, charset, decode_msg, len);
bputs(b, ">");
for (s = text; *s;) {
Index: prayer-1.0.18/prayer/cmd_rm.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_rm.c 2007-03-10 19:38:54.669455249 +0100
+++ prayer-1.0.18/prayer/cmd_rm.c 2007-03-10 19:39:30.914122325 +0100
@@ -32,16 +32,20 @@ void cmd_rm(struct session *session)
bprintf(b,
"<h2 align=\"center\">Confirm directory deletion: \"%s\"</h2>"
CRLF,
- string_canon_decode(pool_strdup
- (request->pool, request->argv[2])));
+ utf8_from_imaputf7(request->pool,
+ string_canon_decode(pool_strdup
+ (request->pool,
+ request->argv[2]))));
} else {
html_start(session, b, "Confirm Mail folder deletion");
bprintf(b,
"<h2 align=\"center\">Confirm folder deletion: \"%s\"</h2>"
CRLF,
- string_canon_decode(pool_strdup
- (request->pool, request->argv[2])));
+ utf8_from_imaputf7(request->pool,
+ string_canon_decode(pool_strdup
+ (request->pool,
+ request->argv[2]))));
}
cmd = pool_printf(request->pool, "rm1/%s/%s",
Index: prayer-1.0.18/prayer/cmd_rm1.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_rm1.c 2007-03-10 19:38:54.719461687 +0100
+++ prayer-1.0.18/prayer/cmd_rm1.c 2007-03-10 19:39:30.944126189 +0100
@@ -55,7 +55,7 @@ void cmd_rm1(struct session *session)
session_message(session, "%s", ml_errmsg()); /* Includes name */
} else {
session_message(session, "Deleted directory: \"%s\"", mailbox);
- dircache_delete(session->dircache, mailbox);
+ dircache_delete(session->dircache, utf8_from_imaputf7(request->pool, mailbox));
}
} else {
ml_delete(session, stream,
@@ -67,7 +67,8 @@ void cmd_rm1(struct session *session)
} else if (ml_have_error()) {
session_message(session, "%s", ml_errmsg()); /* Includes name */
} else {
- session_message(session, "Deleted mailbox: \"%s\"", mailbox);
+ session_message(session, "Deleted mailbox: \"%s\"",
+ utf8_from_imaputf7(request->pool, mailbox));
dircache_delete(session->dircache, mailbox);
if (favourite_delete(fl, mailbox))
options->save = T;
Index: prayer-1.0.18/prayer/cmd_subscribe.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_subscribe.c 2007-03-10 19:38:54.769468126 +0100
+++ prayer-1.0.18/prayer/cmd_subscribe.c 2007-03-10 19:39:30.954127477 +0100
@@ -23,7 +23,7 @@ void cmd_subscribe(struct session *sessi
if (favourite_add(fl, name)) {
options->save = T;
session_message(session, "Added %s to favourites list",
- name);
+ utf8_from_imaputf7(request->pool, name));
} else
session_message(session, "Already on favourites list",
name);
Index: prayer-1.0.18/prayer/cmd_transfer.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_transfer.c 2007-03-10 19:38:54.829475852 +0100
+++ prayer-1.0.18/prayer/cmd_transfer.c 2007-03-10 19:39:30.994132629 +0100
@@ -93,7 +93,7 @@ generate_directory_line(struct session *
html_session_bprintf(session, b,
"<td><a href=\"", "\">" CRLF, "transfer?cwd=%s",
name);
- html_quote_string(b, dir);
+ html_quote_string(b, utf8_from_imaputf7(pool, dir));
bprintf(b, "</a></td>" CRLF);
bputs(b, "<td>&nbsp;</td>" CRLF);
@@ -125,7 +125,7 @@ generate_favourite_folder_line(struct se
bputs(b, "</a></td>" CRLF);
bputs(b, "<td><a>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bputs(b, "</a></td>" CRLF);
bprintf(b, "<td><a href=\"%s/NOSEQ/transfer/%s/%s\">" CRLF,
@@ -159,7 +159,7 @@ generate_folder_line(struct session *ses
bputs(b, "</a></td>" CRLF);
bputs(b, "<td>" CRLF);
- html_quote_string(b, folder);
+ html_quote_string(b, utf8_from_imaputf7(pool, folder));
bputs(b, "</td>" CRLF);
bprintf(b, "<td><a href=\"%s/NOSEQ/transfer/%s/%s\">" CRLF,
@@ -197,8 +197,8 @@ html_folderlist(struct session *session,
else
bputs(b, "<tr>");
bputs(b, "<td><table><tr><td>" CRLF);
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "submit", "Apply");
bputs(b, "</td></tr></table></td>" CRLF);
bputs(b, "<td align=\"right\"><table><tr><td>" CRLF);
@@ -332,7 +332,8 @@ static BOOL download(struct session *ses
OP_READONLY);
if (!session->xfer_stream) {
- session_message(session, "Failed to open mail folder: %s", name);
+ session_message(session, "Failed to open mail folder: %s",
+ utf8_from_imaputf7(request->pool, name));
session_log(session,
"[cmd_transfer] Failed to open mail folder: %s", name);
return (NIL);
@@ -343,7 +344,7 @@ static BOOL download(struct session *ses
/* Fetch overview for all messages in folder */
if (!ml_fetch_overview(session, tstream, "1:*", NIL)) {
session_message(session, "Failed to fetch folder overview: %s",
- name);
+ utf8_from_imaputf7(request->pool, name));
session_log(session,
"[cmd_transfer]] Failed to fetch overview: %s", name);
return (NIL);
Index: prayer-1.0.18/prayer/cmd_unsubscribe.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_unsubscribe.c 2007-03-10 19:38:54.919487442 +0100
+++ prayer-1.0.18/prayer/cmd_unsubscribe.c 2007-03-10 19:39:31.014135204 +0100
@@ -23,10 +23,11 @@ void cmd_unsubscribe(struct session *ses
if (favourite_delete(fl, name)) {
options->save = T;
session_message(session, "Removed %s from favourites list",
- name);
+ utf8_from_imaputf7(request->pool, name));
} else
session_message(session,
- "Folder %s not on favourites list", name);
+ "Folder %s not on favourites list",
+ utf8_from_imaputf7(request->pool, name));
} else
session_message(session,
"String contained illegal characters");
Index: prayer-1.0.18/prayer/cmd_upload_select.c
===================================================================
--- prayer-1.0.18.orig/prayer/cmd_upload_select.c 2007-03-10 19:38:54.969493881 +0100
+++ prayer-1.0.18/prayer/cmd_upload_select.c 2007-03-10 19:39:31.034137781 +0100
@@ -122,8 +122,8 @@ html_folderlist(struct session *session,
/* Change directory form, including back button */
html_form_start(session, b, "GET", "upload_select");
- html_form_field(b, "Directory", "cwd", session->cwd, 32);
- html_form_field(b, "Filter", "filter", session->dir_filter, 12);
+ html_form_field(b, "Directory", "cwd", utf8_from_imaputf7(pool, session->cwd), 32);
+ html_form_field(b, "Filter", "filter", utf8_from_imaputf7(pool, session->dir_filter), 12);
html_form_submit(b, "submit", "Apply");
html_form_end(b);
Index: prayer-1.0.18/prayer/draft.c
===================================================================
--- prayer-1.0.18.orig/prayer/draft.c 2007-03-10 19:38:55.019500318 +0100
+++ prayer-1.0.18/prayer/draft.c 2007-03-10 19:39:31.074142931 +0100
@@ -477,7 +477,7 @@ void draft_update_body(struct draft *d,
} else
d->body = pool_strdup(d->pool, d->body);
- draft_transliterate_1252((unsigned char *)d->body);
+ /*draft_transliterate_1252((unsigned char *)d->body);*/
}
/* draft_update() ********************************************************
@@ -535,7 +535,7 @@ void draft_update(struct draft *d, struc
else
d->body = pool_maybe_strdup(d->pool, d->body);
- draft_transliterate_1252((unsigned char *)d->body);
+ /*draft_transliterate_1252((unsigned char *)d->body);*/
d->in_reply_to = pool_maybe_strdup(d->pool, d->in_reply_to);
d->references = pool_maybe_strdup(d->pool, d->references);
@@ -1164,7 +1164,7 @@ static void draft_make_multipart(struct
bprintf(b, CRLF "--%s" CRLF, cookie);
bputs(b,
- "Content-Type: text/plain; format=flowed; charset=ISO-8859-1"
+ "Content-Type: text/plain; format=flowed; charset=UTF-8"
CRLF);
if (need_qprint)
bputs(b, "Content-Transfer-Encoding: QUOTED-PRINTABLE" CRLF);
@@ -1323,7 +1323,7 @@ static void draft_make_single_part(struc
need_qprint = T;
bputs(b,
- "Content-Type: text/plain; format=flowed; charset=ISO-8859-1"
+ "Content-Type: text/plain; format=flowed; charset=UTF-8"
CRLF);
if (need_qprint)
bputs(b, "Content-Transfer-Encoding: quoted-printable" CRLF);
@@ -1418,7 +1418,7 @@ char *draft_make_msg(struct draft *draft
/* Encode using temporary buffer if required */
s = (char *) rfc1522_encode(tmp, len,
- (unsigned char *) s, "ISO-8859-1");
+ (unsigned char *) s, "UTF-8");
bprintf(mb, "Subject: %s" CRLF, s);
free(tmp);
}
Index: prayer-1.0.18/prayer/html.c
===================================================================
--- prayer-1.0.18.orig/prayer/html.c 2007-03-10 19:38:55.069506757 +0100
+++ prayer-1.0.18/prayer/html.c 2007-03-10 19:39:31.134150660 +0100
@@ -35,7 +35,7 @@ void html_start(struct session *session,
bprintf(b, "<title>Webmail service: %s</title>" CRLF, title);
bputs(b, "<meta name=\"robots\" content=\"none\">" CRLF);
bputs(b, ("<meta http-equiv=\"Content-Type\" "
- "content=\"text/html; charset=ISO-8859-1\">" CRLF));
+ "content=\"text/html; charset=UTF-8\">" CRLF));
bputs(b, "</head>" CRLF);
bputs(b, "<body");
@@ -502,7 +502,7 @@ void
html_form_start(struct session *s, struct buffer *b, char *method,
char *cmd)
{
- bprintf(b, "<form method=\"%s\" accept-charset=\"ISO-8859-1\"",
+ bprintf(b, "<form method=\"%s\" accept-charset=\"UTF-8\"",
method);
html_session_bputs(s, b, " action=\"", "\">" CRLF, cmd);
}
@@ -854,7 +854,7 @@ html_banner_toolbar_favourites(struct se
string_canon_encode(request->pool, li->name));
}
- html_quote_string(b, li->name);
+ html_quote_string(b, utf8_from_imaputf7(request->pool, li->name));
bputs(b, "</option>" CRLF);
}
bputs(b, "</select>" CRLF);
@@ -926,14 +926,14 @@ html_banner_toolbar_folders(struct sessi
if (prefix) {
bprintf(b, "<option value=\"%s%s\">",
prefix, string_canon_encode(request->pool, dl->name));
- html_quote_string(b, session->cwd);
+ html_quote_string(b, utf8_from_imaputf7(request->pool, session->cwd));
html_quote_string(b, "/");
- html_quote_string(b, dl->name);
+ html_quote_string(b, utf8_from_imaputf7(request->pool, dl->name));
bputs(b, "</option>" CRLF);
} else if (strcasecmp(dl->name, "INBOX") != 0) {
bprintf(b, "<option value=\"%s\">",
string_canon_encode(request->pool, dl->name));
- html_quote_string(b, dl->name);
+ html_quote_string(b, utf8_from_imaputf7(request->pool, dl->name));
bputs(b, "</option>" CRLF);
}
}
@@ -1077,7 +1077,8 @@ html_banner_toolbar(struct session *sess
void html_quote_char(struct buffer *b, unsigned char c)
{
if (c > 127) {
- bprintf(b, "&#%lu;", (unsigned long) c);
+ /*bprintf(b, "&#%lu;", (unsigned long) c);*/
+ bputc(b, c);
} else
switch (c) {
case '"':
Index: prayer-1.0.18/prayer/prayer_session.h
===================================================================
--- prayer-1.0.18.orig/prayer/prayer_session.h 2007-03-10 19:39:29.243907238 +0100
+++ prayer-1.0.18/prayer/prayer_session.h 2007-03-10 19:39:31.844242104 +0100
@@ -74,3 +74,4 @@ extern int errno; /* just
#include "checksum.h"
#include "wrap.h"
#include "portlist.h"
+#include "utf8.h"
Index: prayer-1.0.18/prayer/response.c
===================================================================
--- prayer-1.0.18.orig/prayer/response.c 2007-03-10 19:38:55.169519634 +0100
+++ prayer-1.0.18/prayer/response.c 2007-03-10 19:39:31.904249831 +0100
@@ -405,7 +405,7 @@ void response_error(struct request *requ
bputs(b, "Expires: ");
response_date_string(b, time(NIL));
bputs(b, "" CRLF);
- bprintf(b, "Content-Type: text/html; charset=iso-8859-1" CRLF);
+ bprintf(b, "Content-Type: text/html; charset=UTF-8" CRLF);
bprintf(b, "Content-Length: %lu" CRLF,
buffer_size(request->write_buffer));
response_header_end(request);
@@ -437,7 +437,7 @@ void response_html(struct request *reque
/* Generate simple header block for HTML */
response_header_start(request, status);
- bputs(b, "Content-Type: text/html; charset=iso-8859-1" CRLF);
+ bputs(b, "Content-Type: text/html; charset=UTF-8" CRLF);
#ifdef STELLA_HACK
bputs(b, "Expires: ");
Index: prayer-1.0.18/prayer/rfc1522.c
===================================================================
--- prayer-1.0.18.orig/prayer/rfc1522.c 2007-03-10 19:38:55.249529936 +0100
+++ prayer-1.0.18/prayer/rfc1522.c 2007-03-10 19:39:31.934253696 +0100
@@ -162,6 +162,7 @@ char **charset;
unsigned char *rv = NULL, *p;
char *start = s, *sw, *cset, *enc, *txt, *ew, **q, *lang;
unsigned long l;
+ unsigned char *src;
int i;
*d = '\0'; /* init destination */
@@ -171,15 +172,16 @@ char **charset;
while (s && (sw = strstr(s, RFC1522_INIT))) {
/* validate the rest of the encoded-word */
if (rfc1522_valid(sw, &cset, &enc, &txt, &ew)) {
- if (!rv)
+ if (!rv)
rv = d; /* remember start of dest */
/* copy everything between s and sw to destination */
for (i = 0; &s[i] < sw; i++)
if (!isspace((unsigned char) s[i])) { /* if some non-whitespace */
- while (s < sw && d - rv < len - 1)
- *d++ = (unsigned char) *s++;
-
+ /* Assume that any 8 bit characters are Latin-1 */
+ utf8_print(VAR_CHAR_SET, NULL,
+ &d, len - (d - rv) - 1,
+ (unsigned char**)&s, sw - s);
break;
}
@@ -188,23 +190,12 @@ char **charset;
if ((lang = strchr(cset, '*')))
*lang++ = '\0';
-
- /* Insert text explaining charset if we don't know what it is */
- if ((strcasecmp((char *) cset, VAR_CHAR_SET))
- && strcasecmp((char *) cset, "US-ASCII")) {
- if (charset) {
- if (!*charset) /* only write first charset */
- *charset = cpystr(cset);
- } else {
- if (d - rv < len - 1)
- *d++ = '[';
-
- sstrncpy((char **) &d, cset, len - 1 - (d - rv));
- if (d - rv < len - 1)
- *d++ = ']';
- if (d - rv < len - 1)
- *d++ = SPACE;
- }
+ if (!*cset) {
+ cset = UNKNOWN_CHARSET;
+ }
+ if (charset) {
+ if (!*charset) /* only write first charset */
+ *charset = cpystr(cset);
}
/* based on encoding, write the encoded text to output buffer */
@@ -228,15 +219,14 @@ char **charset;
} else
q = NULL;
- if ((p =
+ if ((src = p =
rfc822_qprint((unsigned char *) txt, strlen(txt),
&l))) {
- strncpy((char *) d, (char *) p, len - 1 - (d - rv));
- d[len - 1 - (d - rv)] = '\0';
+ utf8_print(cset, VAR_CHAR_SET,
+ &d, len - 1 - (d - rv),
+ &src, l);
+ *d = '\0';
fs_give((void **) &p); /* free encoded buf */
- d += l; /* advance dest ptr to EOL */
- if (d - rv > len - 1)
- d = rv + len - 1;
} else {
if (q)
fs_give((void **) &q);
@@ -255,22 +245,26 @@ char **charset;
case 'B': /* 'B' encoding */
case 'b':
- if ((p =
+ if ((src = p =
rfc822_base64((unsigned char *) txt, strlen(txt),
&l))) {
- strncpy((char *) d, (char *) p, len - 1 - (d - rv));
- d[len - 1 - (d - rv)] = '\0';
+ utf8_print(cset, VAR_CHAR_SET,
+ &d, len - 1 - (d - rv),
+ &src, l);
+ *d = '\0';
fs_give((void **) &p); /* free encoded buf */
- d += l; /* advance dest ptr to EOL */
- if (d - rv > len - 1)
- d = rv + len - 1;
} else
goto bogus;
break;
+ bogus:
default:
- sstrncpy((char **) &d, txt, len - 1 - (d - rv));
+ src = txt;
+ utf8_print(VAR_CHAR_SET, NULL,
+ &d, len - 1 - (d - rv),
+ (unsigned char **)&src, ew - txt);
+ *d = '\0';
break;
}
@@ -283,6 +277,7 @@ char **charset;
if (lang)
lang[-1] = '*';
+
} else {
/*
@@ -291,28 +286,38 @@ char **charset;
/* if already copying to destn, copy it */
if (rv) {
- strncpy((char *) d, s,
- (int) min((l = (sw - s) + RFC1522_INIT_L),
- len - 1 - (d - rv)));
- d += l; /* advance d, tie off text */
- if (d - rv > len - 1)
- d = rv + len - 1;
+ utf8_print(VAR_CHAR_SET, NULL,
+ &d, len - 1 - (d - rv),
+ (unsigned char**)&s, sw - s);
*d = '\0';
- s += l; /* advance s beyond intro */
} else
s += ((sw - s) + RFC1522_INIT_L);
}
}
- if (rv && *s) /* copy remaining text */
- strncat((char *) rv, s, len - 1 - strlen((char *) rv));
+ if (rv && *s) { /* copy remaining text */
+ utf8_print(VAR_CHAR_SET, NULL,
+ &d, len - 1 - (d - rv),
+ (unsigned char**)&s, strlen(s));
+ *d = '\0';
+ }
/* BUG: MUST do code page mapping under DOS after decoding */
- return (rv ? rv : (unsigned char *) start);
+ if (rv) return rv;
+
+ for (s = start; *s; s++) {
+ if (*s & 0x80) {
+ rv = d;
+ utf8_print(VAR_CHAR_SET, NULL,
+ &d, len - 1,
+ (unsigned char**)&start, strlen(s));
+ *d = '\0';
+ return rv;
- bogus:
- return ((unsigned char *) start);
+ }
+ }
+ return (unsigned char *) start;
}
@@ -364,7 +369,7 @@ int c;
int rfc1522_valenc(c)
int c;
{
- return (!(c == '?' || c == SPACE) && isprint((unsigned char) c));
+ return (!(c == '?' /*|| c == SPACE*/) && isprint((unsigned char) c));
}
@@ -386,7 +391,7 @@ char **endp;
&e)
&& rfc1522_token(++e, rfc1522_valtok, RFC1522_DLIM, &t)
&& rfc1522_token(++t, rfc1522_valenc, RFC1522_TERM, &p)
- && p - s <= RFC1522_MAXW;
+ /* && p - s <= RFC1522_MAXW */;
if (charset)
*charset = c;
Index: prayer-1.0.18/prayer/utf8.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ prayer-1.0.18/prayer/utf8.c 2007-03-10 19:39:31.974258848 +0100
@@ -0,0 +1,418 @@
+/* Copyright (c) Magnus Holmgren <magnus@kibibyte.se>,
+ * <holmgren@lysator.liu.se>
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include "prayer_session.h"
+#include <iconv.h>
+
+#define JNK 0177
+#define UNI_REPLACEMENT_CHAR 0x0000FFFD
+#define UNI_REPLACEMENT_CHAR_UTF8 "\xEF\xBF\xBD"
+#define ICONV_CHUNK_SIZE 1024
+
+/* utf8_from_imaputf7() ***********************************************
+ *
+ * Convert a string encoded as modified UTF-7 to UTF-8.
+ * pool: Target pool for storage
+ * t: The string to convert
+ *
+ * Returns: A new, UTF-8-encoded string
+ *
+ * Note: This function tries hard to return something useful in case
+ * the input string is invalid in some way, rather than bail out
+ * and return NULL.
+ **********************************************************************/
+
+char *utf8_from_imaputf7(struct pool *pool, char *t)
+{
+ struct buffer *b = buffer_create(pool, 64);
+ BOOL base64mode = NIL;
+ int i, j;
+ unsigned char buf[4];
+ unsigned char *s;
+ unsigned long scalar; /* Unicode scalar value */
+ unsigned char c;
+
+ static char decode_base64[256] = {
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,076,077,JNK,JNK,JNK,
+ 064,065,066,067,070,071,072,073,074,075,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,000,001,002,003,004,005,006,007,010,011,012,013,014,015,016,
+ 017,020,021,022,023,024,025,026,027,030,031,JNK,JNK,JNK,JNK,JNK,
+ JNK,032,033,034,035,036,037,040,041,042,043,044,045,046,047,050,
+ 051,052,053,054,055,056,057,060,061,062,063,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,
+ JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK,JNK
+ };
+
+ if (!t) return NULL;
+
+ for (s = (unsigned char*)t; *s; s++) {
+ if (base64mode) {
+ if (*s == '-') {
+ if (j != 0 || c != 0) /* Some junk left */ {
+ bputs(b, UNI_REPLACEMENT_CHAR_UTF8);
+ }
+ base64mode = NIL;
+ continue;
+ }
+
+ if (decode_base64[*s] == JNK) {
+ break; /* Bail out */
+ }
+
+ switch (i++) {
+ case 0:
+ /* Top 6 bits of the first octet */
+ c = decode_base64[*s] << 2; break;
+ case 1:
+ /* Top 2 bits are bottom 2 bits of the first octet */
+ buf[j++] = c | (decode_base64[*s] >> 4);
+ /* and bottom 4 bits are top 4 bits of the second */
+ c = decode_base64[*s] << 4; break;
+ case 2:
+ /* Top 4 bits are bottom 4 bits of the second octet */
+ buf[j++] = c | (decode_base64[*s] >> 2);
+ /* and bottom 2 bits are top 2 bits of the third */
+ c = decode_base64[*s] << 6; break;
+ case 3:
+ /* Bottom 6 bits of the third octet */
+ buf[j++] = c | decode_base64[*s];
+ i = 0;
+ }
+
+ /* Check if we have a complete UTF-16 character */
+ if (j == 4) { /* We should now have a surrogate pair */
+ scalar = ((buf[0] & 3) << 18) + (buf[1] << 10)
+ + ((buf[2] & 3) << 8) + buf[3] + 0x10000;
+ }
+ else if (j == 2) {
+ if (buf[0] < 0xD8 || buf[0] > 0xDF) {
+ scalar = (buf[0] << 8) + buf[1];
+ }
+ else if (buf[0] > 0xDB) {
+ /* Error - invalid surrogate */
+ scalar = UNI_REPLACEMENT_CHAR;
+ }
+ else {
+ /* High surrogate found - need low surrogate */
+ continue;
+ }
+ }
+ else continue; /* Odd number of bytes */
+
+ if (scalar >= 0x110000) scalar = UNI_REPLACEMENT_CHAR;
+
+ if (scalar < 0x80) {
+ bputc(b, (unsigned char)scalar);
+ j = 0;
+ continue;
+ } else if (scalar < 0x800) {
+ bputc(b, 0xC0 | (scalar >> 6));
+ } else if (scalar < 0x10000) {
+ bputc(b, 0xE0 | (scalar >> 12));
+ } else {
+ bputc(b, 0xF0 | (scalar >> 18));
+ }
+
+ if (scalar >= 0x10000)
+ bputc(b, 0x80 | ((scalar >> 12) & 0x3F));
+ if (scalar >= 0x800)
+ bputc(b, 0x80 | ((scalar >> 6) & 0x3F));
+ bputc(b, 0x80 | (scalar & 0x3F));
+ j = 0;
+
+ }
+ else /* !base64mode */ {
+ if (*s == '&') {
+ if (*(s+1) == '-') {
+ bputc(b, '&');
+ s++;
+ }
+ else {
+ base64mode = T;
+ i = 0; j = 0; c = 0;
+ }
+ }
+ else {
+ bputc(b, *s);
+ }
+ }
+ }
+ return buffer_fetch(b, 0, buffer_size(b), NIL);
+}
+
+
+/* utf8_to_imaputf7() *************************************************
+ *
+ * Convert a string encoded as UTF-8 to modified UTF-7.
+ * pool: Target pool for storage
+ * t: The string to convert
+ *
+ * Returns: A new string encoded as modified UTF-7
+ *
+ * Note: This function tries hard to return something useful in case
+ * the input string is invalid in some way, rather than bail out
+ * and return NULL.
+ **********************************************************************/
+
+char *utf8_to_imaputf7(struct pool *pool, char *t)
+{
+ unsigned char *s;
+ struct buffer *b = buffer_create(pool, 64);
+ BOOL base64mode = NIL;
+ unsigned long scalar;
+ unsigned int L, i, j;
+ unsigned char buf[4];
+ unsigned char c = 0;
+
+ static char encode_base64[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
+ if (!t) return NULL;
+
+ for (s = (unsigned char *)t; *s; s++) {
+ if (*s < 0x7f && *s >= 0x20) {
+ if (base64mode) {
+ switch (i) {
+ case 1:
+ /* Remaining bottom 2 bits of the last octet */
+ bputc(b, encode_base64[c << 4]); break;
+ case 2:
+ /* Remaining bottom 4 bits of the last octet */
+ bputc(b, encode_base64[c << 2]);
+ }
+ bputc(b, '-');
+ base64mode = NIL;
+ }
+ bputc(b, *s);
+ if (*s == '&') {
+ bputc(b, '-');
+ }
+ }
+ else {
+ if (*s < 0x80) {
+ L = 0; scalar = *s;
+ } else if ((*s & 0xE0) == 0xC0) {
+ L = 1; scalar = (*s & 0x1F);
+ } else if ((*s & 0xF0) == 0xE0) {
+ L = 2; scalar = (*s & 0x0F);
+ } else if ((*s & 0xF8) == 0xF0) {
+ L = 3; scalar = (*s & 0x07);
+ } else if ((*s & 0xFC) == 0xF8) {
+ L = 4; scalar = (*s & 0x03);
+ } else if ((*s & 0xFE) == 0xFC) {
+ L = 5; scalar = (*s & 0x01);
+ } else {
+ L = 0; scalar = UNI_REPLACEMENT_CHAR;
+ }
+
+ for (j = 0; j < L; j++) {
+ s++;
+ if ((*s & 0xC0) == 0x80) {
+ scalar <<= 6;
+ scalar |= (*s & 0x3F);
+ }
+ else {
+ s--;
+ scalar = UNI_REPLACEMENT_CHAR;
+ }
+ }
+
+ if (!base64mode) {
+ bputc(b, '&');
+ base64mode = T;
+ i = 0;
+ }
+ if (scalar <= 0xFFFF) {
+ buf[1] = scalar & 0xFF;
+ scalar >>= 8;
+ buf[0] = scalar & 0xFF;
+ L = 2;
+ }
+ else {
+ scalar -= 0x100000UL;
+ buf[3] = scalar & 0xFF;
+ scalar >>= 8;
+ buf[2] = 0xDC | (scalar & 0x03);
+ scalar >>= 2;
+ buf[3] = scalar & 0xFF;
+ scalar >>= 8;
+ buf[1] = 0xD8 | (scalar & 0x03);
+ L = 4;
+ }
+
+ for (j = 0; j < L; j++) {
+ switch (i++) {
+ case 0:
+ /* Top 6 bits of the first octet */
+ bputc(b, encode_base64[(buf[j] >> 2) & 0x3F]);
+ c = (buf[j] & 0x03); break;
+ case 1:
+ /* Bottom 2 bits of the first octet, and top 4 bits of the second */
+ bputc(b, encode_base64[(c << 4) |
+ ((buf[j] >> 4) & 0x0F)]);
+ c = (buf[j] & 0x0F); break;
+ case 2:
+ /* Bottom 4 bits of the second octet and top 2 bits of the third */
+ bputc(b, encode_base64[(c << 2) |
+ ((buf[j] >> 6) & 0x03)]);
+ /* Bottom 6 bits of the third octet */
+ bputc(b, encode_base64[buf[j] & 0x3F]);
+ i = 0;
+ }
+ }
+
+ }
+ }
+ if (base64mode) {
+ switch (i) {
+ case 1:
+ /* Remaining bottom 2 bits of the last octet */
+ bputc(b, encode_base64[c << 4]); break;
+ case 2:
+ /* Remaining bottom 4 bits of the last octet */
+ bputc(b, encode_base64[c << 2]);
+ }
+ bputc(b, '-');
+ base64mode = NIL;
+ }
+ return buffer_fetch(b, 0, buffer_size(b), NIL);
+}
+
+
+/* utf8_from_string() ************************************************
+ *
+ * Convert a string with given character encoding to UTF-8
+ *
+ * pool: Pool to allocate memory from
+ * charset: Charset of input string
+ * t: String to convert
+ * len: Length of string
+ ***********************************************************************/
+
+char *utf8_from_string(struct pool *pool, char *charset, char *t, unsigned long len)
+{
+ struct buffer *b;
+ char chunk[ICONV_CHUNK_SIZE];
+ char *outbuf;
+ size_t outbytesleft;
+ size_t result;
+ int i;
+ iconv_t cd = iconv_open("UTF-8", charset);
+ b = buffer_create(pool, 1024);
+
+ if (cd == (iconv_t)(-1)) {
+ buffer_printf(b, "(Conversion from %s failed)", charset);
+ }
+ else while (len) {
+ outbuf = chunk;
+ outbytesleft = ICONV_CHUNK_SIZE;
+ result = iconv(cd, &t, (size_t*)&len, &outbuf, &outbytesleft);
+ for (i = 0; i < ICONV_CHUNK_SIZE - outbytesleft; i++) {
+ bputc(b, chunk[i]);
+ }
+ if (result == (size_t)(-1)) switch (errno) {
+ case E2BIG:
+ break;
+ case EILSEQ:
+ case EINVAL:
+ /* Try skipping a byte */
+ t++;
+ len--;
+ bputs(b, UNI_REPLACEMENT_CHAR_UTF8);
+ break;
+ default:
+ iconv_close(cd);
+ return NULL;
+ }
+ }
+
+ iconv_close(cd);
+ return buffer_fetch(b, 0, buffer_size(b), NIL);
+}
+
+BOOL utf8_print(char *charset, char *fallback_charset,
+ unsigned char **dst, unsigned long dst_size,
+ unsigned char **src, unsigned long src_size)
+{
+
+ iconv_t cd = iconv_open("UTF-8", charset);
+ if (cd == (iconv_t)(-1) && fallback_charset)
+ cd = iconv_open("UTF-8", fallback_charset);
+
+ while (iconv(cd, (char**)src, (size_t*)&src_size,
+ (char**)dst, (size_t*)&dst_size) == (size_t)(-1)) {
+ switch (errno) {
+ case EILSEQ:
+ case EINVAL:
+ /* Try skipping a byte */
+ (*src)++;
+ src_size--;
+ if (dst_size >= sizeof(UNI_REPLACEMENT_CHAR_UTF8)) {
+ strcpy((char*)*dst, UNI_REPLACEMENT_CHAR_UTF8);
+ }
+ if (errno == EILSEQ) break;
+ case E2BIG:
+ default:
+ iconv_close(cd);
+ return NIL;
+ }
+ }
+ iconv_close(cd);
+ return T;
+}
+
+/* utf8_prune() ********************************************************
+ *
+ * Like string_prune, but counts UTF-8 multibyte sequences as units.
+ * pool: Target pool
+ * s: UTF-8 string to prune
+ * maxlen: Maximum length of string before pruning applies.
+ *
+ * Returns: Pruned string, maximum maxlen characters (not bytes), not
+ * counting the terminating null.
+ ***********************************************************************/
+
+char *utf8_prune(struct pool *pool, char *s, unsigned long maxlen)
+{
+ char *result;
+ unsigned long cutoff;
+ unsigned long L;
+ unsigned long i = 0;
+
+ if (maxlen < (strlen("...") + 1))
+ return (s);
+
+ for (L = 0; L < maxlen; L++) {
+ if (s[i] == '\0') return s;
+ if (L == maxlen - strlen("...")) cutoff = i;
+
+ if (s[i] & 0x80)
+ while (s[i] & 0x80) i++;
+ else
+ i++;
+ }
+
+ result = pool_alloc(pool, cutoff + 4);
+ memcpy(result, s, cutoff);
+ strcpy(result + cutoff, "...");
+
+ return (result);
+
+}
Index: prayer-1.0.18/prayer/utf8.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ prayer-1.0.18/prayer/utf8.h 2007-03-10 19:39:32.004262711 +0100
@@ -0,0 +1,7 @@
+char *utf8_from_imaputf7(struct pool *pool, char *t);
+char *utf8_to_imaputf7(struct pool *pool, char *t);
+char *utf8_from_string(struct pool *pool, char *charset, char *t, unsigned long len);
+BOOL utf8_print(char *charset, char *fallback_charset,
+ unsigned char **dst, unsigned long dst_size,
+ unsigned char **src, unsigned long src_size);
+char *utf8_prune(struct pool *pool, char *s, unsigned long maxlen);
/trunk/debian/patches/makefile_install_config.patch
1,5 → 1,5
--- prayer-1.1.0.orig/files/etc/prayer-accountd.cf
+++ prayer-1.1.0/files/etc/prayer-accountd.cf
--- prayer-1.0.18.orig/files/etc/prayer-accountd.cf
+++ prayer-1.0.18/files/etc/prayer-accountd.cf
@@ -8,6 +8,8 @@
# Default accountd.cf file suitable for RedHat Linux only.
# See distribution for some sample files for FreeBSD and Solaris
9,9 → 9,9
msforward_name = ".MSforward"
forward_name = ".forward"
aliases_name = "vacation.aliases"
--- prayer-1.1.0.orig/files/Makefile
+++ prayer-1.1.0/files/Makefile
@@ -53,41 +53,44 @@ distclean:
--- prayer-1.0.18.orig/files/Makefile
+++ prayer-1.0.18/files/Makefile
@@ -53,41 +53,44 @@
install-cert:
if [ -f certs/prayer.pem ]; then \
$(INSTALL) -o $(RO_USER) -g $(RO_GROUP) \
69,8 → 69,8
- ./init.d/prayer $(BROOT)/etc/rc.d/init.d/prayer
+ ./init.d/prayer $(DESTDIR)/etc/rc.d/init.d/prayer
#chkconfig prayer --level 2345 on
--- prayer-1.1.0.orig/files/install.sh
+++ prayer-1.1.0/files/install.sh
--- prayer-1.0.18.orig/files/install.sh
+++ prayer-1.0.18/files/install.sh
@@ -4,77 +4,6 @@
PATH=/bin:/sbin/:/usr/bin:/usr/sbin
143,15 → 143,15
-fi
-
-if [ ! -d ${BIN_DIR} ]; then
- ${INSTALL} -d -o ${RO_USER} -g ${RO_GROUP} -m ${PUBLIC_DIR} ${BIN_DIR}
- ${INSTALL} -d -o ${RO_USER} -g ${RO_GROUP} -m ${PRIVATE_DIR} ${BIN_DIR}
-fi
-
for i in help icons
do
if [ -d "${PREFIX}/${i}" ]; then
--- prayer-1.1.0.orig/files/etc/prayer.cf.SRC
+++ prayer-1.1.0/files/etc/prayer.cf.SRC
@@ -20,7 +20,7 @@ var_prefix = "__VAR_PREFIX__"
--- prayer-1.0.18.orig/files/etc/prayer.cf.SRC
+++ prayer-1.0.18/files/etc/prayer.cf.SRC
@@ -20,7 +20,7 @@
# User ID to run as if we start off as root
prayer_user = "prayer"
# Group ID to run as if we start off as root
160,7 → 160,7
# Run prayer as background process.
# TRUE => will return as soon as valid configuration is found.
@@ -428,14 +428,14 @@ bin_dir = "__BIN_DIR__"
@@ -423,14 +423,14 @@
# Various directories used by the running system
# Logs stored in $log_dir
178,7 → 178,7
# Split socket directory into 64 subdirs keyed on first letter of sessionID
# Code provides compatibility in both directions: can switch back and forward
@@ -446,14 +446,14 @@ socket_split_dir = TRUE
@@ -441,14 +441,14 @@
init_socket_name = init
# $ssl_session_dir is location for SSL session cache
196,7 → 196,16
# Interface to Hermes finger database
#lookup_rpasswd = "/data/finger/rpasswd.cdb"
@@ -614,7 +614,7 @@ sent_mail_folder = "sent-mail"
@@ -587,7 +587,7 @@
suppress_dotfiles = TRUE
# Mail directory in users account
-maildir = "mail"
+maildir = ""
# Temporary hack to remove "mail/" from favourites list (and anywhere
# else where we find the strings embedded into .prayer files).
@@ -601,7 +601,7 @@
# default_domain = "<valid mail domain>"
# Language for ispell.
205,9 → 214,9
# Size of small and large compose windows
small_cols = 80
--- prayer-1.1.0.orig/prayer/Makefile
+++ prayer-1.1.0/prayer/Makefile
@@ -102,8 +102,9 @@ ifeq ($(strip $(CCLIENT_KERB_ENABLE)), t
--- prayer-1.0.18.orig/prayer/Makefile
+++ prayer-1.0.18/prayer/Makefile
@@ -102,8 +102,9 @@
SESSION_LIBS += $(KERB_LIBS)
endif
219,7 → 228,7
SHARED_OBJS = \
pool.o list.o assoc.o memblock.o buffer.o string.o config.o user_agent.o \
@@ -175,21 +176,21 @@ clean:
@@ -175,21 +176,21 @@
install: all
$(INSTALL) -o $(RO_USER) -g $(RO_GROUP) -m $(PUBLIC_DIR) -d \
/trunk/debian/patches/session_server_bugs.patch
0,0 → 1,12
--- prayer-1.0.18.orig/prayer/session_server.c
+++ prayer-1.0.18/prayer/session_server.c
@@ -375,7 +375,8 @@
if (!os_signal_child_init(os_child_reaper))
return (NIL);
- name = pool_strcat(NIL, config->socket_dir, "/init");
+ name = pool_printf(NIL, "%s/%s",
+ config->socket_dir, config->init_socket_name);
if ((sockfd = os_bind_unix_socket(name)) < 0)
return (NIL);
/trunk/debian/patches/pidfiles_extension.patch
0,0 → 1,22
--- prayer-1.0.18.orig/prayer/prayer_main.c
+++ prayer-1.0.18/prayer/prayer_main.c
@@ -111,7 +111,7 @@
static BOOL prayer_main_write_pid(struct config *config)
{
- char *name = pool_printf(NIL, "%s/prayer", config->pid_dir);
+ char *name = pool_printf(NIL, "%s/prayer.pid", config->pid_dir);
FILE *file;
if ((file = fopen(name, "w")) == NIL)
--- prayer-1.0.18.orig/prayer/session_main.c
+++ prayer-1.0.18/prayer/session_main.c
@@ -32,7 +32,7 @@
static BOOL session_main_write_pid(struct config *config)
{
- char *name = pool_printf(NIL, "%s/prayer-session", config->pid_dir);
+ char *name = pool_printf(NIL, "%s/prayer-session.pid", config->pid_dir);
FILE *file;
if ((file = fopen(name, "w")) == NIL)
/trunk/debian/patches/series
1,2 → 1,8
includes.patch
makefile_install_config.patch
session_unix_bugs.patch
session_server_bugs.patch
hasnochildren_means_noinferiors.patch
pidfiles_extension.patch
ipv6.patch
utf8.patch
/trunk/debian/changelog
1,17 → 1,3
prayer (1.1.0-1) unstable; urgency=low
 
* First upload to unstable.
* New upstream release.
- Drop pidfiles_extension.patch, session_unix_bugs.patch,
session_server_bugs.patch; all incorporated upstream.
- Drop ipv6.patch; incorporated upstream.
- Drop utf8.patch; incorporated and improved upstream.
- Drop hasnochildren_means_noinferiors.patch since upstream now
handles dual-use mailboxes.
* New maintainer email address.
 
-- Magnus Holmgren <holmgren@debian.org> Fri, 18 Apr 2008 18:45:05 +0200
 
prayer (1.0.18-1) experimental; urgency=low
 
* Initial release (Closes: #392823)