Bug 160488 - Rewrite header adds the new header too many times
Summary: Rewrite header adds the new header too many times
Status: RESOLVED NOT A BUG
Alias: None
Product: kmail
Classification: Applications
Component: filtering (show other bugs)
Version: 1.9.50
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-06 21:20 UTC by András Manţia
Modified: 2008-04-15 18:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description András Manţia 2008-04-06 21:20:14 UTC
Version:            (using Devel)
Installed from:    Compiled sources

For some mails I need to rewrite the header Content-Type, otherwise KMail uses the wrong encoding for it.
So I set up a filter:
Rewrite header: Content-Type
Replace: . (tried with empty field as well)
With: text/plain;charset="iso-8859-2"

The original mail was:
Content-Type: text/plain;
  charset=ISO-8859-1

After I applied the filter manually:
Content-Type: text/plain;
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2";
  charset="iso-8859-2"

If I apply the filter again on the same message I get much-much-more (several pages) of
  charset="iso-8859-2";
Comment 1 Thomas McGuire 2008-04-15 18:19:09 UTC
That is not a bug.
The "Rewrite Header" filter rule will replace each occurence of the given text with something else.
In your case, you used ".", which is the regular expression for "any character".
So each character will be replaces with "text/plain;charset="iso-8859-2"", leading to many of those strings.
Use a better regular expression, preferable something that matches the incorrect charset only.

KMail also has a fallback character encoding for the reader window, see the config options (though that only works in the lastest SVN version).