You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Jasha Joachimsthal (JIRA)" <ji...@apache.org> on 2006/03/29 16:08:21 UTC

[jira] Created: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

SendMailTransformer misses closing tag when recipient address is malformed
--------------------------------------------------------------------------

         Key: COCOON-1818
         URL: http://issues.apache.org/jira/browse/COCOON-1818
     Project: Cocoon
        Type: Bug
  Components: Blocks: Mail  
    Reporter: Jasha Joachimsthal


When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Jasha Joachimsthal (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1818?page=all ]

Jasha Joachimsthal updated COCOON-1818:
---------------------------------------

    Attachment: SendMailTransformer.diff

Simone, thank you for making the changes. 
I moved soms other lines of code too so the SendMailTransformer won't stop if one address is invalid. 
The diff is not a delta from yours but a new one.

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: SendMailTransformer.diff, sendmail-exceptions.diff, sendmail-exceptions2.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Jasha Joachimsthal (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12414052 ] 

Jasha Joachimsthal commented on COCOON-1818:
--------------------------------------------

Could someone please commit the SendMailTransformer.diff so this bug is fixed? Thanks

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: SendMailTransformer.diff, sendmail-exceptions.diff, sendmail-exceptions2.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Jean-Baptiste Quenot (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12372389 ] 

Jean-Baptiste Quenot commented on COCOON-1818:
----------------------------------------------

Simone, it's a very good idea to propagate exceptions.  Indeed it makes no sense to catch the exceptions and report them in the pipeline result.  The same applies to many Cocoon components, like SQLTransformer.

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12372447 ] 

Simone Gianni commented on COCOON-1818:
---------------------------------------

Ok, I'll try .. 

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Jasha Joachimsthal (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12372443 ] 

Jasha Joachimsthal commented on COCOON-1818:
--------------------------------------------

My solution was like #3 (not sure whether email:error should be inside email:result or outside like it is now) but the last time I did something in Java was in the 20th century so I want someone else at Hippo to have a look at it. :)

Other thing. If you send it to 10 addresses and it creates an exception, at address 6, it stops and 7-10 won't get the mail. Is this behaviour correct, disirable or not?

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Jasha Joachimsthal (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12372436 ] 

Jasha Joachimsthal commented on COCOON-1818:
--------------------------------------------

This fix will cause other problems (the result tag is not always present, e.g. when the smtp host is incorrect). I am working on it, hope to post something asap.

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1818?page=all ]

Simone Gianni updated COCOON-1818:
----------------------------------

    Attachment: sendmail-exceptions2.diff

This patch applies the solution number 3 : for every call to the sendMail() method a result element is always generated. It will contain an error, an exception, or the common email sent results. 

This changes the produced XML in many ways :
- The error element was not conained in a result before this patch.
- The exception element was or was not contained in a result before this patch (and this caused the main problems)

So consider that after applying you'll probably have to change the XSL that transforms the result.

If a mail is not sent, it should not stop sending all the others, unless a SAXException is received (in that case the pipeline is probably broken, so there's nothing cocoon can do about it). Maybe you've seen it stopping because of the inconsistent XML, which caused a SAXException, which stops everything.

P.S. this patch is not a delta from the previous one, so you should revert the file on which you applied the previous patch and the apply this one on the clean reverted file.

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff, sendmail-exceptions2.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12372442 ] 

Simone Gianni commented on COCOON-1818:
---------------------------------------

IMMO, it's a good idea to report an exception indicating that a single email was not sent in the XML report. This is useful to report to the user which email was invialid, and more important since sending a bunch of emails is not transactional, it's not possible to rollback, and this if the entire batch sending is aborted with an exception when an email fails there would be no way to avoid sending some emails more than once.

Jasha, you are completely right : if the exception happens before the result element is opened, with my patch it would be closed anyway, so there are three possible solutions :
1) Use a boolean to indicate that the result element was opened, and check this boolean before closing it in the finally. Pros are that it's simple to implement, cons are that the result XML will have sometimes have a result containing an exception, other times only the exception not wrapped inside a result.
2) Open the result element always after everything has been done, so that a result will always contain the result of a good email, while exceptions will always be reported outside the result element.
3) Open the result element always before everything is done, so that an exception will always be wrapped inside a result, wether it happens at the very early stage of email sending or at the last step of it.

I think the number 3 is the best one. It should not be that hard to implement, just moving the start element up in the code as much as possible (if possible, at the first line of the sendMail method).

Jasha, do you want to try? :)

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Simone Gianni (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1818?page=all ]

Simone Gianni updated COCOON-1818:
----------------------------------

    Attachment: sendmail-exceptions.diff

I'm not an expert about this block, but i made the following modifications :
- The sendEndElementEventNS is now called inside a finally, this way the output is <result><exception>...</exception></result>
- A SAXException is now propagated up to when it happens in sendMail, since IMMO it makes no sense to intercept a SAXException and try to generate an exception report producing more SAX events.

The only thing i'm not sure is the this.ignoreHookCount-- . But since it's SAX related i moved it to the finally as well as the sendEndElementEventNS.

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Helma van der Linden (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1818?page=comments#action_12372459 ] 

Helma van der Linden commented on COCOON-1818:
----------------------------------------------

Sorry to chip in so late, but when I was looking at this class I noticed a FIXME that states that it would be a good idea to use the same MailSender component that is used for the SendMailAction and SendMail XSP logicsheet.

I've started working on this and it seemed rather straightforward, but unfortunately something crashed and I lost the modified code before I was able to properly finish and test it.

So how about killing two birds with one stone and see if the class can be improved by using the MailSender component as well as fixing this bug? Maybe using the component already fixes this bug. At the very least, the behaviour will be consistent.

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>          Key: COCOON-1818
>          URL: http://issues.apache.org/jira/browse/COCOON-1818
>      Project: Cocoon
>         Type: Bug
>   Components: Blocks: Mail
>     Reporter: Jasha Joachimsthal
>  Attachments: sendmail-exceptions.diff, sendmail-exceptions2.diff
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (COCOON-1818) SendMailTransformer misses closing tag when recipient address is malformed

Posted by "Andrew Savory (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1818?page=all ]

Andrew Savory closed COCOON-1818.
---------------------------------

    Resolution: Fixed

Patch applied. Thanks Simone and Jasha!

> SendMailTransformer misses closing tag when recipient address is malformed
> --------------------------------------------------------------------------
>
>                 Key: COCOON-1818
>                 URL: http://issues.apache.org/jira/browse/COCOON-1818
>             Project: Cocoon
>          Issue Type: Bug
>          Components: Blocks: Mail
>            Reporter: Jasha Joachimsthal
>         Attachments: sendmail-exceptions.diff, sendmail-exceptions2.diff, SendMailTransformer.diff
>
>
> When a recipient address contains an illegal character (, ; <space> a@b@com etc), an exception is being thrown by method sendMail(List newAddresses, Transport trans).
> The execution of the try in method sendMail() is stopped which may have created a <email:result> tag. 
> No </email:result> end tag is created when this occurs.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira