Regex Help

Hi Phil,

The format for the signing trigger is not exactly a regular expression. The format is as follows (see the admin guide).

HEADER-NAME:REG-EXP

So, the part before the : should be the name of the header and the part after : should be a reg expression that matches the header value.

The main reason for this is that header values can be encoded (for example base64) and should be decoded before matching. The downside is that you can only match one header and multiple headers. If you want to match multiple headers you add another matcher to config.xml (the file that describes the mail flow).

I can add support for multiple headers by allowing comma separated header names. If you want this feature can you add a feature request to jira?

Kind regards,

Martijn Brinkers

···

---
Sent with DJIGZO for Android. Please excuse my brevity.

----- Original message -----
Hmmm. I found this site which is a simple Java regex tester:

http://www.cis.upenn.edu/~matuszek/General/RegexTester/regex-tester.html

I deconstructed my regex and then rebuilt it step by step until I had no further Syntax Exceptions and ended up with :

(?i)(subject\s:\s\[sign\].*)|(x-secure-sign\s:\strue)

running this through the tester using a sample of:

Subject : [sign] test

resulted in the following:

start() = 0, end() = 21
group(0) = "Subject : [sign] test"
group(1) = "Subject : [sign] test"
group(2) = "null"

so that pattern worked perfectly. I then took that same regex and applied it to the signing trigger in Djigzo and it threw an error again:

03 Aug 2012 14:49:59 | WARN Invalid pattern. Trigger: (?i)(subject\s:\s\[sign\].*)|(x-secure-sign\s:\strue) (mitm.application.djigzo.james.matchers.SenderHeaderTrigger) [Spool Thread #3]
java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 11
\s\[sign\].*)|(x-secure-sign\s:\strue)

Bizarre! ;(
--
Thanks, Phil

----- Original Message -----

Still unable to get this to work :frowning: What JAVA package does Djigzo use
for its regex ? Wondering if there is a way of testing outside of
Djigzo.
--
Thanks, Phil

----- Original Message -----
> Still the same:
>
> 02 Aug 2012 09:56:02 | WARN Invalid pattern. Trigger:
> (?i)(^subject
> \:\s\[sign\]|^x-secure-sign \:\strue$)
> (mitm.application.djigzo.james.matchers.SenderHeaderTrigger)
> [Spool Thread #3]
> java.util.regex.PatternSyntaxException: Unmatched closing ')' near
> index 34
> \s\[sign\]|^x-secure-sign \:\strue$)
>
> I also tried double bracing the regex from examples I have see
> on-line for groupings:
>
> (?i)(^subject \:\s\[sign\])|(^x-secure-sign \:\strue$)
> --
> Thanks, Phil
>
> ----- Original Message -----
> > Can you try to see whether escaping: works (I.e., using \: )
> >
> > Kind regards,
> >
> > Martijn Brinkers
> >
> > ---
> > Sent with DJIGZO for Android. Please excuse my brevity.
> >
> > ----- Original message -----
> > Am attempting to use the following signing regex trigger:
> >
> > (?i)(^subject :\s\[sign\]|^x-secure-sign :\strue$)
> >
> > but when I review the log file I am seeing:
> >
> > 02 Aug 2012 09:25:03 | WARN Invalid pattern. Trigger:
> > (?i)(^subject
> > :\s\[sign\]|^x-secure-sign :\strue$)
> > (mitm.application.djigzo.james.matchers.SenderHeaderTrigger)
> > [Spool
> > Thread #0]
> > java.util.regex.PatternSyntaxException: Unmatched closing ')'
> > near
> > index 33
> > \s\[sign\]|^x-secure-sign :\strue$)
> > ^
> > The braces match so am missing why the parser believes they are
> > unmatched ?
> >
> > --
> > Thanks, Phil
> >
> > _______________________________________________
> > Users mailing list
> > Users(a)lists.djigzo.com
> > http://lists.djigzo.com/lists/listinfo/users
> >
> >
> _______________________________________________
> Users mailing list
> Users(a)lists.djigzo.com
> http://lists.djigzo.com/lists/listinfo/users
>
_______________________________________________
Users mailing list
Users(a)lists.djigzo.com
http://lists.djigzo.com/lists/listinfo/users

_______________________________________________
Users mailing list
Users(a)lists.djigzo.com
http://lists.djigzo.com/lists/listinfo/users

Hello Martijn,

thanks for the clarification. I will open a JIRA as it is a very important feature to allow it to work across all mail clients.

···

--
Thanks, Phil

----- Original Message -----

Hi Phil,

The format for the signing trigger is not exactly a regular
expression. The format is as follows (see the admin guide).

HEADER-NAME:REG-EXP

So, the part before the : should be the name of the header and the
part after : should be a reg expression that matches the header
value.

The main reason for this is that header values can be encoded (for
example base64) and should be decoded before matching. The downside
is that you can only match one header and multiple headers. If you
want to match multiple headers you add another matcher to config.xml
(the file that describes the mail flow).

I can add support for multiple headers by allowing comma separated
header names. If you want this feature can you add a feature request
to jira?

Kind regards,

Martijn Brinkers

---
Sent with DJIGZO for Android. Please excuse my brevity.

----- Original message -----
Hmmm. I found this site which is a simple Java regex tester:

http://www.cis.upenn.edu/~matuszek/General/RegexTester/regex-tester.html

I deconstructed my regex and then rebuilt it step by step until I had
no further Syntax Exceptions and ended up with :

(?i)(subject\s:\s\[sign\].*)|(x-secure-sign\s:\strue)

running this through the tester using a sample of:

Subject : [sign] test

resulted in the following:

start() = 0, end() = 21
group(0) = "Subject : [sign] test"
group(1) = "Subject : [sign] test"
group(2) = "null"

so that pattern worked perfectly. I then took that same regex and
applied it to the signing trigger in Djigzo and it threw an error
again:

03 Aug 2012 14:49:59 | WARN Invalid pattern. Trigger:
(?i)(subject\s:\s\[sign\].*)|(x-secure-sign\s:\strue)
   (mitm.application.djigzo.james.matchers.SenderHeaderTrigger)
[Spool Thread #3]
java.util.regex.PatternSyntaxException: Unmatched closing ')' near
index 11
\s\[sign\].*)|(x-secure-sign\s:\strue)

Bizarre! ;(
--
Thanks, Phil

----- Original Message -----
> Still unable to get this to work :frowning: What JAVA package does Djigzo
> use
> for its regex ? Wondering if there is a way of testing outside of
> Djigzo.
> --
> Thanks, Phil
>
> ----- Original Message -----
> > Still the same:
> >
> > 02 Aug 2012 09:56:02 | WARN Invalid pattern. Trigger:
> > (?i)(^subject
> > \:\s\[sign\]|^x-secure-sign \:\strue$)
> > (mitm.application.djigzo.james.matchers.SenderHeaderTrigger)
> > [Spool Thread #3]
> > java.util.regex.PatternSyntaxException: Unmatched closing ')'
> > near
> > index 34
> > \s\[sign\]|^x-secure-sign \:\strue$)
> >
> > I also tried double bracing the regex from examples I have see
> > on-line for groupings:
> >
> > (?i)(^subject \:\s\[sign\])|(^x-secure-sign \:\strue$)
> > --
> > Thanks, Phil
> >
> > ----- Original Message -----
> > > Can you try to see whether escaping: works (I.e., using \: )
> > >
> > > Kind regards,
> > >
> > > Martijn Brinkers
> > >
> > > ---
> > > Sent with DJIGZO for Android. Please excuse my brevity.
> > >
> > > ----- Original message -----
> > > Am attempting to use the following signing regex trigger:
> > >
> > > (?i)(^subject :\s\[sign\]|^x-secure-sign :\strue$)
> > >
> > > but when I review the log file I am seeing:
> > >
> > > 02 Aug 2012 09:25:03 | WARN Invalid pattern. Trigger:
> > > (?i)(^subject
> > > :\s\[sign\]|^x-secure-sign :\strue$)
> > > (mitm.application.djigzo.james.matchers.SenderHeaderTrigger)
> > > [Spool
> > > Thread #0]
> > > java.util.regex.PatternSyntaxException: Unmatched closing ')'
> > > near
> > > index 33
> > > \s\[sign\]|^x-secure-sign :\strue$)
> > > ^
> > > The braces match so am missing why the parser believes they are
> > > unmatched ?
> > >
> > > --
> > > Thanks, Phil
> > >
> > > _______________________________________________
> > > Users mailing list
> > > Users(a)lists.djigzo.com
> > > http://lists.djigzo.com/lists/listinfo/users
> > >
> > >
> > _______________________________________________
> > Users mailing list
> > Users(a)lists.djigzo.com
> > http://lists.djigzo.com/lists/listinfo/users
> >
> _______________________________________________
> Users mailing list
> Users(a)lists.djigzo.com
> http://lists.djigzo.com/lists/listinfo/users
>
_______________________________________________
Users mailing list
Users(a)lists.djigzo.com
http://lists.djigzo.com/lists/listinfo/users