[sane-devel] xsane and qmail
Dave Williams
dave at opensourcesolutions.co.uk
Fri Nov 3 23:17:42 CET 2006
QMail is strict regarding the format of emails. It rejects emails not
conforming to 822bis section 2.3, which prohibits all bare LFs.
Unfortunately this is what xsane-email sends in its message body.
The patch below corrects this. It shouldnt break operation with any
other mail daemons although I'm not in a position to check specifically.
Hopefully it can be included in the next release.
Dave
diff -Naur xsane-0.991/src/xsane-email-project.c xsane-0.991a/src/xsane-email-project.c
--- xsane-0.991/src/xsane-email-project.c 2006-01-10 18:07:44.000000000 +0000
+++ xsane-0.991a/src/xsane-email-project.c 2006-11-03 22:03:39.000000000 +0000
@@ -1595,7 +1595,7 @@
/* doc files like ps and pdf can not be displayed inline in html email */
if (display_images_inline)
{
- snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\n", content_id);
+ snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\r\n", content_id);
}
write(fd, buf, strlen(buf));
}
@@ -1605,7 +1605,7 @@
}
else if (*email_text_pos == 10) /* new line */
{
- snprintf(buf, sizeof(buf), "<br>\n");
+ snprintf(buf, sizeof(buf), "<br>\r\n");
write(fd, buf, strlen(buf));
}
else
@@ -1624,12 +1624,12 @@
/* doc files like ps and pdf can not be displayed inline in html email */
if (display_images_inline)
{
- snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\n", content_id);
+ snprintf(buf, sizeof(buf), "<p><img SRC=\"cid:%s\">\r\n", content_id);
}
write(fd, buf, strlen(buf));
}
- snprintf(buf, sizeof(buf), "</html>\n");
+ snprintf(buf, sizeof(buf), "</html>\r\n");
write(fd, buf, strlen(buf));
@@ -1666,7 +1666,7 @@
write_email_mime_ascii(fd, boundary);
write(fd, email_text, strlen(email_text));
- write(fd, "\n\n", 2);
+ write(fd, "\r\n\r\n", 4);
for (i=0; i<attachments; i++)
{
diff -Naur xsane-0.991/src/xsane-save.c xsane-0.991a/src/xsane-save.c
--- xsane-0.991/src/xsane-save.c 2006-01-10 17:46:32.000000000 +0000
+++ xsane-0.991a/src/xsane-save.c 2006-11-03 22:03:39.000000000 +0000
@@ -5477,7 +5477,7 @@
pos += 4;
if (pos > 71)
{
- write(fd_socket, "\n", 1);
+ write(fd_socket, "\r\n", 2);
pos = 0;
}
@@ -5492,7 +5492,7 @@
if (pos)
{
- write(fd_socket, "\n", 1);
+ write(fd_socket, "\r\n", 2);
}
xsane.email_progress_val = 1.0;
@@ -5505,33 +5505,33 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "From: %s\n", from);
+ snprintf(buf, sizeof(buf), "From: %s\r\n", from);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Reply-To: %s\n", reply_to);
+ snprintf(buf, sizeof(buf), "Reply-To: %s\r\n", reply_to);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "To: %s\n", to);
+ snprintf(buf, sizeof(buf), "To: %s\r\n", to);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Subject: %s\n", subject);
+ snprintf(buf, sizeof(buf), "Subject: %s\r\n", subject);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "MIME-Version: 1.0\n");
+ snprintf(buf, sizeof(buf), "MIME-Version: 1.0\r\n");
write(fd_socket, buf, strlen(buf));
if (related) /* related means that we need a special link in the html part to display the image */
{
- snprintf(buf, sizeof(buf), "Content-Type: multipart/related;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: multipart/related;\r\n");
write(fd_socket, buf, strlen(buf));
}
else
{
- snprintf(buf, sizeof(buf), "Content-Type: multipart/mixed;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: multipart/mixed;\r\n");
write(fd_socket, buf, strlen(buf));
}
- snprintf(buf, sizeof(buf), " boundary=\"%s\"\n\n", boundary);
+ snprintf(buf, sizeof(buf), " boundary=\"%s\"\r\n\r\n", boundary);
write(fd_socket, buf, strlen(buf));
}
@@ -5541,7 +5541,7 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s--\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s--\r\n", boundary);
write(fd_socket, buf, strlen(buf));
}
@@ -5551,16 +5551,16 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: text/plain;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: text/plain;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " charset=\"iso-8859-1\"\n");
+ snprintf(buf, sizeof(buf), " charset=\"iso-8859-1\"\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 8bit\n\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 8bit\r\n\r\n");
write(fd_socket, buf, strlen(buf));
}
@@ -5570,22 +5570,22 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: text/html;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: text/html;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " charset=\"us-ascii\"\n");
+ snprintf(buf, sizeof(buf), " charset=\"us-ascii\"\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 7bit\n\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 7bit\r\n\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n");
+ snprintf(buf, sizeof(buf), "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "<html>\n");
+ snprintf(buf, sizeof(buf), "<html>\r\n");
write(fd_socket, buf, strlen(buf));
}
@@ -5595,28 +5595,28 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: %s\n", content_type);
+ snprintf(buf, sizeof(buf), "Content-Type: %s\r\n", content_type);
write(fd_socket, buf, strlen(buf));
if (content_id)
{
- snprintf(buf, sizeof(buf), "Content-ID: <%s>\n", content_id);
+ snprintf(buf, sizeof(buf), "Content-ID: <%s>\r\n", content_id);
write(fd_socket, buf, strlen(buf));
}
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Disposition: inline;\n");
+ snprintf(buf, sizeof(buf), "Content-Disposition: inline;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " filename=\"%s\"\n", filename);
+ snprintf(buf, sizeof(buf), " filename=\"%s\"\r\n", filename);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "\n");
+ snprintf(buf, sizeof(buf), "\r\n");
write(fd_socket, buf, strlen(buf));
write_base64(fd_socket, infile);
@@ -5628,25 +5628,25 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: application/octet-stream\n");
+ snprintf(buf, sizeof(buf), "Content-Type: application/octet-stream\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " name=\"%s\"\n", filename);
+ snprintf(buf, sizeof(buf), " name=\"%s\"\r\n", filename);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Disposition: attachment;\n");
+ snprintf(buf, sizeof(buf), "Content-Disposition: attachment;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " filename=\"%s\"\n", filename);
+ snprintf(buf, sizeof(buf), " filename=\"%s\"\r\n", filename);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "\n");
+ snprintf(buf, sizeof(buf), "\r\n");
write(fd_socket, buf, strlen(buf));
write_base64(fd_socket, infile);
diff -Naur xsane-0.991/src/xsane-save.c.orig xsane-0.991a/src/xsane-save.c.orig
--- xsane-0.991/src/xsane-save.c.orig 2005-12-17 12:37:25.000000000 +0000
+++ xsane-0.991a/src/xsane-save.c.orig 2006-11-03 22:03:38.000000000 +0000
@@ -5366,7 +5366,7 @@
pos += 4;
if (pos > 71)
{
- write(fd_socket, "\n", 1);
+ write(fd_socket, "\r\n", 2);
pos = 0;
}
@@ -5381,7 +5381,7 @@
if (pos)
{
- write(fd_socket, "\n", 1);
+ write(fd_socket, "\r\n", 2);
}
xsane.mail_progress_val = 1.0;
@@ -5394,33 +5394,33 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "From: %s\n", from);
+ snprintf(buf, sizeof(buf), "From: %s\r\n", from);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Reply-To: %s\n", reply_to);
+ snprintf(buf, sizeof(buf), "Reply-To: %s\r\n", reply_to);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "To: %s\n", to);
+ snprintf(buf, sizeof(buf), "To: %s\r\n", to);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Subject: %s\n", subject);
+ snprintf(buf, sizeof(buf), "Subject: %s\r\n", subject);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "MIME-Version: 1.0\n");
+ snprintf(buf, sizeof(buf), "MIME-Version: 1.0\r\n");
write(fd_socket, buf, strlen(buf));
if (related) /* related means that we need a special link in the html part to display the image */
{
- snprintf(buf, sizeof(buf), "Content-Type: multipart/related;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: multipart/related;\r\n");
write(fd_socket, buf, strlen(buf));
}
else
{
- snprintf(buf, sizeof(buf), "Content-Type: multipart/mixed;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: multipart/mixed;\r\n");
write(fd_socket, buf, strlen(buf));
}
- snprintf(buf, sizeof(buf), " boundary=\"%s\"\n\n", boundary);
+ snprintf(buf, sizeof(buf), " boundary=\"%s\"\r\n\r\n", boundary);
write(fd_socket, buf, strlen(buf));
}
@@ -5430,7 +5430,7 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s--\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s--\r\n", boundary);
write(fd_socket, buf, strlen(buf));
}
@@ -5440,16 +5440,16 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: text/plain;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: text/plain;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " charset=\"iso-8859-1\"\n");
+ snprintf(buf, sizeof(buf), " charset=\"iso-8859-1\"\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 8bit\n\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 8bit\r\n\r\n");
write(fd_socket, buf, strlen(buf));
}
@@ -5459,22 +5459,22 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: text/html;\n");
+ snprintf(buf, sizeof(buf), "Content-Type: text/html;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " charset=\"us-ascii\"\n");
+ snprintf(buf, sizeof(buf), " charset=\"us-ascii\"\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 7bit\n\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: 7bit\r\n\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n");
+ snprintf(buf, sizeof(buf), "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "<html>\n");
+ snprintf(buf, sizeof(buf), "<html>\r\n");
write(fd_socket, buf, strlen(buf));
}
@@ -5484,28 +5484,28 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: %s\n", content_type);
+ snprintf(buf, sizeof(buf), "Content-Type: %s\r\n", content_type);
write(fd_socket, buf, strlen(buf));
if (content_id)
{
- snprintf(buf, sizeof(buf), "Content-ID: <%s>\n", content_id);
+ snprintf(buf, sizeof(buf), "Content-ID: <%s>\r\n", content_id);
write(fd_socket, buf, strlen(buf));
}
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Disposition: inline;\n");
+ snprintf(buf, sizeof(buf), "Content-Disposition: inline;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " filename=\"%s\"\n", filename);
+ snprintf(buf, sizeof(buf), " filename=\"%s\"\r\n", filename);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "\n");
+ snprintf(buf, sizeof(buf), "\r\n");
write(fd_socket, buf, strlen(buf));
write_base64(fd_socket, infile);
@@ -5517,25 +5517,25 @@
{
char buf[1024];
- snprintf(buf, sizeof(buf), "--%s\n", boundary);
+ snprintf(buf, sizeof(buf), "--%s\r\n", boundary);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Type: application/octet-stream\n");
+ snprintf(buf, sizeof(buf), "Content-Type: application/octet-stream\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " name=\"%s\"\n", filename);
+ snprintf(buf, sizeof(buf), " name=\"%s\"\r\n", filename);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\n");
+ snprintf(buf, sizeof(buf), "Content-Transfer-Encoding: base64\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "Content-Disposition: attachment;\n");
+ snprintf(buf, sizeof(buf), "Content-Disposition: attachment;\r\n");
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), " filename=\"%s\"\n", filename);
+ snprintf(buf, sizeof(buf), " filename=\"%s\"\r\n", filename);
write(fd_socket, buf, strlen(buf));
- snprintf(buf, sizeof(buf), "\n");
+ snprintf(buf, sizeof(buf), "\r\n");
write(fd_socket, buf, strlen(buf));
write_base64(fd_socket, infile);
More information about the sane-devel
mailing list