James jSieve
  1. James jSieve
  2. JSIEVE-57

Parse failure with multi-line form when the line begins with a dot

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.2
    • Fix Version/s: 0.4
    • Component/s: JSieve (Main)
    • Labels:
      None

      Description

      I'm having some trouble with dot-stuffing in a multi-line form. When I try to parse the script below, I get a syntax exception on the line that starts with "..":

      org.apache.jsieve.parser.generated.TokenMgrError: Lexical error at line 8, column 1. Encountered: "." (46), after : ""

      require ["fileinto", "reject", "tag", "flag"];

      1. reply filter
        if anyof (header :contains "subject" "reply") { reply ["user2@cosmonaut.zimbra.com", "user3@cosmonaut.zimbra.com"] "text:" This is the first line This is the second line ..This is a line that begins with a dot And here's a dot by itself: .. The end . ; stop; }

        Activity

        Hide
        Boris Burtin added a comment -

        Looks like this problem is bigger than I thought. I can't even get a simple form without dot-stuffing to work. Parsing this simple script:

        require ["fileinto", "reject", "tag", "flag"];

        1. reply
          if anyof (header :contains "subject" "test reply") { reply "text:" This is the first line This is the second line . ; stop; }

        results in

        org.apache.jsieve.parser.generated.TokenMgrError: Lexical error at line 8, column 1. Encountered: "." (46), after : ""
        at org.apache.jsieve.parser.generated.SieveParserTokenManager.getNextToken(SieveParserTokenManager.java:609)
        at org.apache.jsieve.parser.generated.SieveParser.getToken(SieveParser.java:625)
        at org.apache.jsieve.parser.generated.SieveParser.jjtreeOpenNodeScope(SieveParser.java:10)

        Show
        Boris Burtin added a comment - Looks like this problem is bigger than I thought. I can't even get a simple form without dot-stuffing to work. Parsing this simple script: require ["fileinto", "reject", "tag", "flag"] ; reply if anyof (header :contains "subject" "test reply") { reply "text:" This is the first line This is the second line . ; stop; } results in org.apache.jsieve.parser.generated.TokenMgrError: Lexical error at line 8, column 1. Encountered: "." (46), after : "" at org.apache.jsieve.parser.generated.SieveParserTokenManager.getNextToken(SieveParserTokenManager.java:609) at org.apache.jsieve.parser.generated.SieveParser.getToken(SieveParser.java:625) at org.apache.jsieve.parser.generated.SieveParser.jjtreeOpenNodeScope(SieveParser.java:10)
        Show
        Robert Burrell Donkin added a comment - See http://markmail.org/thread/lfieoeutduebbrkr
        Hide
        Robert Burrell Donkin added a comment -

        <blockquote cite='http://tools.ietf.org/html/rfc5228'>
        For entering larger amounts of text, such as an email message, a
        multi-line form is allowed. It starts with the keyword "text:",
        followed by a CRLF, and ends with the sequence of a CRLF, a single
        period, and another CRLF. The CRLF before the final period is
        considered part of the value. In order to allow the message to
        contain lines with a single dot, lines are dot-stuffed. That is,
        when composing a message body, an extra '.' is added before each line
        that begins with a '.'. When the server interprets the script, these
        extra dots are removed. Note that a line that begins with a dot
        followed by a non-dot character is not interpreted as dot-stuffed;
        that is, ".foo" is interpreted as ".foo". However, because this is
        potentially ambiguous, scripts SHOULD be properly dot-stuffed so such
        lines do not appear.
        </blockquote>

        Show
        Robert Burrell Donkin added a comment - <blockquote cite='http://tools.ietf.org/html/rfc5228'> For entering larger amounts of text, such as an email message, a multi-line form is allowed. It starts with the keyword "text:", followed by a CRLF, and ends with the sequence of a CRLF, a single period, and another CRLF. The CRLF before the final period is considered part of the value. In order to allow the message to contain lines with a single dot, lines are dot-stuffed. That is, when composing a message body, an extra '.' is added before each line that begins with a '.'. When the server interprets the script, these extra dots are removed. Note that a line that begins with a dot followed by a non-dot character is not interpreted as dot-stuffed; that is, ".foo" is interpreted as ".foo". However, because this is potentially ambiguous, scripts SHOULD be properly dot-stuffed so such lines do not appear. </blockquote>
        Hide
        Robert Burrell Donkin added a comment -

        Syntax:
        <blockquote cite='http://tools.ietf.org/html/rfc5228'>
        multi-line = "text:" *(SP / HTAB) (hash-comment / CRLF)
        *(multiline-literal / multiline-dotstart)
        "." CRLF

        multiline-literal = [ octet-not-period *octet-not-crlf ] CRLF

        multiline-dotstart = "." 1*octet-not-crlf CRLF
        ; A line containing only "." ends the
        ; multi-line. Remove a leading '.' if
        ; followed by another '.'.
        </blockquote>

        Show
        Robert Burrell Donkin added a comment - Syntax: <blockquote cite='http://tools.ietf.org/html/rfc5228'> multi-line = "text:" *(SP / HTAB) (hash-comment / CRLF) *(multiline-literal / multiline-dotstart) "." CRLF multiline-literal = [ octet-not-period *octet-not-crlf ] CRLF multiline-dotstart = "." 1*octet-not-crlf CRLF ; A line containing only "." ends the ; multi-line. Remove a leading '.' if ; followed by another '.'. </blockquote>
        Hide
        Robert Burrell Donkin added a comment -

        I think that the problem is that commands should not be quoted, so I think that the example above should be:

        require ["fileinto", "reject", "tag", "flag"];

        1. reply
          if anyof (header :contains "subject" "test reply") { reply text: This is the first line This is the second line . ; stop; }

        <blockquote cite='http://www.ietf.org/rfc/rfc3028.txt'>
        9. Extended Example

        The following is an extended example of a Sieve script. Note that it
        does not make use of the implicit keep.

        #

        1. Example Sieve Filter
        2. Declare any optional features or extension used by the script
          #
          require ["fileinto", "reject"];

        #

        1. Reject any large messages (note that the four leading dots get
        2. "stuffed" to three)
          #
          if size :over 1M { reject text: Please do not send me large attachments. Put your file on a server and send me the URL. Thank you. .... Fred . ; stop; }

          #

        </blockquote>

        Show
        Robert Burrell Donkin added a comment - I think that the problem is that commands should not be quoted, so I think that the example above should be: require ["fileinto", "reject", "tag", "flag"] ; reply if anyof (header :contains "subject" "test reply") { reply text: This is the first line This is the second line . ; stop; } <blockquote cite='http://www.ietf.org/rfc/rfc3028.txt'> 9. Extended Example The following is an extended example of a Sieve script. Note that it does not make use of the implicit keep. # Example Sieve Filter Declare any optional features or extension used by the script # require ["fileinto", "reject"] ; # Reject any large messages (note that the four leading dots get "stuffed" to three) # if size :over 1M { reject text: Please do not send me large attachments. Put your file on a server and send me the URL. Thank you. .... Fred . ; stop; } # </blockquote>
        Hide
        Robert Burrell Donkin added a comment -

        I've gone through the code, added the missing processing and test cases. I think that this should now be working ok provided that the text: is not quoted (as per specification)

        Please close this issue if the latest code works for you, or reopen if there are still issues

        Show
        Robert Burrell Donkin added a comment - I've gone through the code, added the missing processing and test cases. I think that this should now be working ok provided that the text: is not quoted (as per specification) Please close this issue if the latest code works for you, or reopen if there are still issues
        Hide
        Boris Burtin added a comment -

        Parsing of multi-line forms is working now, but I think dot-stuffing is still busted. For the following script:

        require ["fileinto", "reject", "tag", "flag"];

        1. reply
          if anyof (header :contains "subject" "reply") { reply text: This is line 1. This is line 2. .......... This is line 3. . ; stop; }

        I get the following value

        This is line 1.
        This is line 2.
        . This is line 3.

        If I understand RFC 3028 section 2.4.2 correctly, shouldn't I get 9 dots when the line in the script is prefixed with 10 dots? Currently, I get only 1.

        Show
        Boris Burtin added a comment - Parsing of multi-line forms is working now, but I think dot-stuffing is still busted. For the following script: require ["fileinto", "reject", "tag", "flag"] ; reply if anyof (header :contains "subject" "reply") { reply text: This is line 1. This is line 2. .......... This is line 3. . ; stop; } I get the following value This is line 1. This is line 2. . This is line 3. If I understand RFC 3028 section 2.4.2 correctly, shouldn't I get 9 dots when the line in the script is prefixed with 10 dots? Currently, I get only 1.
        Hide
        Robert Burrell Donkin added a comment -

        Boris - I agree that this is a bug

        Hopefully this should be fixed in the latest code

        Please reopen if you find any more issues

        Thanks

        Show
        Robert Burrell Donkin added a comment - Boris - I agree that this is a bug Hopefully this should be fixed in the latest code Please reopen if you find any more issues Thanks

          People

          • Assignee:
            Robert Burrell Donkin
            Reporter:
            Boris Burtin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development