tag 586577 + patch
severity 586577 important
thanks
Am 2010-06-29 18:23, schrieb Tim Riemenschneider:
> As a workaround, it works if I install the upsteam-binary instead of the
> debian version
> (i.e. download the xpi from http://enigmail.mozdev.org/download/index.php )
>
> Suggestion comes from ubuntu, which is also affected by this, see:
> https://bugs.launchpad.net/ubuntu/+source/enigmail/+bug/565014
>
> (so it seems debian/ubuntu-specific)
Yes, I know the Ubuntu bug report. The good news is that I wrote a patch
that fixes the problem as far as I've tested. (Attached)
Comments welcome.
WM
Index: enigmail-1.0.1/extensions/enigmail/src/nsEnigMimeListener.cpp
===================================================================
--- enigmail-1.0.1.orig/extensions/enigmail/src/nsEnigMimeListener.cpp 2010-06-29 22:14:37.000000000 +0200
+++ enigmail-1.0.1/extensions/enigmail/src/nsEnigMimeListener.cpp 2010-06-29 22:24:40.000000000 +0200
@@ -675,17 +675,33 @@
}
static void
-__ReplaceCSubstring (nsACString &string, const char* replace, const char* with)
+__ReplaceCSubstring (nsACString &str, const char* replace, const char* with)
{
- PRInt32 i = string.Find (replace);
- string.Replace (i, strlen (replace), with);
+ //Modeled after nsTStringObsolete's ReplaceSubstring implementation
+
+ if(strlen(replace) == 0)
+ return;
+
+ PRInt32 i = 0;
+ while(i < str.Length()) {
+ PRInt32 r = str.Find(replace, strlen(replace));
+ if(r == -1)
+ break;
+ str.Replace(r, strlen(replace), with, strlen(with));
+ i = r + strlen(with);
+ }
+
}
static void
-__ReplaceCChar (nsACString &string, const char replace, const char with)
+__ReplaceCChar (nsACString &str, const char replace, const char with)
{
- PRInt32 i = string.FindChar (replace);
- string.Replace (i, 1, (const char*) &with, 1);
+ PRInt32 i = 0;
+ while(i < str.Length()) {
+ if(str[i] == replace)
+ str.Replace(i,1, &with, 1);
+ ++i;
+ }
}
void
@@ -772,11 +788,11 @@
return;
// Extract header key (not case-sensitive)
- nsCAutoString headerKey = (nsCString) nsDependentCSubstring (headerStr, colonOffset);
+ nsCAutoString headerKey = (nsCString) nsDependentCSubstring (headerStr, 0, colonOffset);
ToLowerCase(headerKey);
// Extract header value, trimming leading/trailing whitespace
- nsCAutoString buf = (nsCString) nsDependentCSubstring (headerStr, colonOffset, headerStr.Length() - colonOffset);
+ nsCAutoString buf = (nsCString) nsDependentCSubstring (headerStr, colonOffset + 1, headerStr.Length() - colonOffset - 1);
buf.Trim(" ");
//DEBUG_LOG(("nsEnigMimeListener::ParseHeader: %s: %s\n", headerKey.get(), buf.get()));
@@ -790,7 +806,7 @@
} else {
// Extract value to left of parameters
- headerValue = nsDependentCSubstring (buf, semicolonOffset);
+ headerValue = nsDependentCSubstring (buf, 0, semicolonOffset);
}
// Trim leading and trailing spaces in header value
Index: enigmail-1.0.1/extensions/enigmail/src/nsEnigMimeService.cpp
===================================================================
--- enigmail-1.0.1.orig/extensions/enigmail/src/nsEnigMimeService.cpp 2010-06-29 22:14:37.000000000 +0200
+++ enigmail-1.0.1/extensions/enigmail/src/nsEnigMimeService.cpp 2010-06-29 22:14:37.000000000 +0200
@@ -218,8 +218,12 @@
static void
__ReplaceChar (nsAString &string, const PRUnichar replace, const PRUnichar with)
{
- PRInt32 i = string.FindChar (replace);
- string.Replace (i, 1, &with, 1);
+ PRInt32 i = 0;
+ while(i < string.Length()) {
+ if(string[i] == replace)
+ string.Replace(i,1, &with, 1);
+ ++i;
+ }
}
NS_IMETHODIMP