diff --git a/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp b/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp index 8a53027810..b924729753 100644 --- a/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/match_header/ConfigView.cpp @@ -50,8 +50,8 @@ RuleFilterConfig::RuleFilterConfig(BMessage *settings) : BView(BRect(0,0,260,85) attr->SetText(settings->FindString("attribute")); AddChild(attr); - regex = new BTextControl(BRect(104,5,255,20),"attr",MDR_DIALECT_CHOICE (" is "," が "),MDR_DIALECT_CHOICE ("value (can be a regular expression, like *spam*)","値(正規表現対応)"),NULL); - regex->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE (" is "," が ")) + 4); + regex = new BTextControl(BRect(104,5,255,20),"attr",MDR_DIALECT_CHOICE (" has "," が "),MDR_DIALECT_CHOICE ("value (use REGEX: in from of regular expressions like *spam*)","値(正規表現対応)"),NULL); + regex->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE (" has "," が ")) + 4); if (settings->HasString("regex")) regex->SetText(settings->FindString("regex")); AddChild(regex); diff --git a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp index 0b4d0b5e71..6f26a4a85f 100644 --- a/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/match_header/RuleFilter.cpp @@ -21,9 +21,16 @@ RuleFilter::RuleFilter(BMessage *settings) : BMailFilter(settings) { attr.CapitalizeEachWord(); attribute = strdup(attr.String()); - const char *regex = NULL; + BString regex; settings->FindString("regex",®ex); - matcher.SetPattern(regex,true); + + int32 index = regex.FindFirst("REGEX:"); + if (index == B_ERROR || index > 0) + EscapeRegexTokens(regex); + else + regex.RemoveFirst("REGEX:"); + + matcher.SetPattern(regex.String(),false); settings->FindString("argument",&arg); settings->FindInt32("do_what",(long *)&do_what); @@ -59,10 +66,10 @@ status_t RuleFilter::ProcessMailMessage if (data == NULL) //--- How would this happen? No idea return B_OK; - + if (!matcher.Match(data)) return B_OK; //-----There wasn't an error. We're just not supposed to do anything - + switch (do_what) { case Z_MOVE_TO: if (io_headers->ReplaceString("DESTINATION",arg) != B_OK)