Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Mail Filtering: Problem Escaping A Period (Regex)

Discussion in 'E-mail Discussion' started by TBear, Jul 3, 2004.

  1. TBear

    TBear Registered

    Joined:
    Jul 3, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    151
    Location:
    Arizona
    "Escaping" a period does not appear to be working (my host using 9.4.1-STABLE Build 65)

    Using "\." (backslash period) to "escape" a period and treat it as a "literal" does not appear to work.

    Here's an example of a filter I'm trying to use:

    $message_headers matches "80\.53\.152\."
    (a backslash precedes each of the 3 periods above)

    Instead of treating the "escaped" periods as literal "periods", they are being treated as the meta character for a wildcard.

    Because the period is NOT being escaped (despite my use of the backslash), the filter above traps:
    80.53.152.
    BUT it also traps
    80-53-152-
    and even
    80a53a152a

    How does one ensure that an "escaped meta character", in this case the "peroid" will be treated as a literal?

    Is there something special I must do to escape a period other than using the backslash? Despite escaping the periods, CPanel/exim continues to treat the periods as wildcards.

    In summary, how can I ensure that Cpanel/exim will treat an escaped meta-character as a literal, not as a wildcard.

    Sorry to be so wordy.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. bjrubble

    bjrubble Registered

    Joined:
    Jul 7, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    151
    I haven't tried unescaping characters this way, but for metacharacters (ie \b, \w, etc) it looks like backslashes get escaped twice along the way, so you need four of them to get a backspace into the final string.

    ie. \\\\b -> \b in the final regex

    so I'd try \\\\. instead of \.
     
  3. Unhindered

    Unhindered Registered

    Joined:
    Feb 22, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    51
    Anwer found

    I was having the same problem. I found the answer in another post: backslashes are stripped a few times, so \+ becomes + .

    FOUR backslashes are needed to equal one.

    My new ongoing problem is that filtering only catches the first email address that matches.

    My filter is set up to redirect username+string@domain.com to username@domain.com

    If I send an email to: username1+string@domain.com AND username2@domain.com, only one email is received, at username1@domain.com

    If I send an email to: username1+string@domain.com AND username2+string@domain.com, only one email is received, at username1@domain.com
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice