You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Theo Van Dinter <fe...@apache.org> on 2006/10/24 18:54:57 UTC

Re: finish() method on the status objects

On Sun, Oct 22, 2006 at 08:13:35PM -0400, Joe Flowers wrote:
> Can I get away with this without any memory or resource leaks? Is this OK?
>   my $spamtest = Mail::SpamAssassin->new();
>   my $status = $spamtest->check($spamtest->parse($message));
[...]
>   $status->finish();

Hrm.  I would normally suggest running $msg->finish(), but in this case, I
believe that the $status->finish() should handle it.  You may also want to
look at M::SA->check_message_text().

-- 
Randomly Selected Tagline:
"Shell programming can be a difficult lesson in frustration."
                      - Linux Reference Manual

Re: finish() method on the status objects

Posted by Theo Van Dinter <fe...@apache.org>.
On Tue, Oct 24, 2006 at 06:06:11PM +0100, Justin Mason wrote:
> > Hrm.  I would normally suggest running $msg->finish(), but in this case, I
> > believe that the $status->finish() should handle it.
> 
> well, I wouldn't recommend assuming it will be supported in future...
> definitely a better idea to call $msg->finish();

For the current 3.x series it should work.  We could definitely change things
in the future, but then we'll have to make check_message_text work or
otherwise get rid of it.

-- 
Randomly Selected Tagline:
Year, n.:
 	A period of three hundred and sixty-five disappointments.
 		-- Ambrose Bierce, "The Devil's Dictionary"

R: R: finish() method on the status objects

Posted by Giampaolo Tomassoni <g....@libero.it>.
> Thanks Giampaolo!  Does this mean that "whatever character you like" 
> cannot show up anywhere else in the string (except the very end)?

Right. 'q' is meant exactly to use, in example, " and ' characters in strings with no escaping mechanism.

There are few exceptions to this trick (i.e.: you end a "q["  with "]", not "["), but more or less you're right.


> Thanks!

You welcome.

Giampaolo

> 
> Joe
> 


Re: R: finish() method on the status objects

Posted by Joe Flowers <fl...@social.chass.ncsu.edu>.
Giampaolo Tomassoni wrote:
>>> You can use any quoting mechanism you like:
>>>
>>> ...("This is a programmer's ...")
>>> ...(q@This is a programmer's ...@)
>>> etc.
>>>       
>> Sorry for the Perl question.
>> Is the "q" in "(q@This is a programmer's ...@)" a typo?
>>     
>
> No, it isn't. It means "QUOTE" and allows you to quote a string with whatever character you like.
>
> Actually, I believe perl itself is a typo...
>
> Giampaolo
>   

Thanks Giampaolo!  Does this mean that "whatever character you like" 
cannot show up anywhere else in the string (except the very end)?

Thanks!

Joe


R: finish() method on the status objects

Posted by Giampaolo Tomassoni <g....@libero.it>.
> > You can use any quoting mechanism you like:
> >
> > ...("This is a programmer's ...")
> > ...(q@This is a programmer's ...@)
> > etc.
> 
> Sorry for the Perl question.
> Is the "q" in "(q@This is a programmer's ...@)" a typo?

No, it isn't. It means "QUOTE" and allows you to quote a string with whatever character you like.

Actually, I believe perl itself is a typo...

Giampaolo

> 
> 
> >> Also, M::SA->check_message_text('This too\') is a problem too 
> because of 
> >>     
> > [...]
> >   
> >> Any ideas on the best way to handle this?
> >>     
> >
> > Well, SA won't help you with general Perl quoting, just so 
> we're clear this
> > isn't SA specific.  You could read the string into a variable 
> then pass the
> > variable, or use one of the above methods, or something like:
> > $variable = <<EOF;
> > This is a programmer's ...
> > blah
> > foo bar
> > EOF
> > ...check_message_text($variable);
> >
> >   
> 
> I'm embedding this is C, so I have a level of C string escaping I have 
> to deal with too, besides not being a Perl programmer.
> And, that's the crux of the original problem and question.
> 
> Joe
> 
> 
> 
> 


Re: finish() method on the status objects

Posted by Joe Flowers <fl...@social.chass.ncsu.edu>.
Theo Van Dinter wrote:
> On Wed, Oct 25, 2006 at 12:57:52PM -0400, Joe Flowers wrote:
>   
>> I'd prefer to use M::SA->check_message_text(), but if I do a 
>> M::SA->check_message_text('This is a programmer's nightmare.'), then 
>> M::SA->check_message_text() will choke because of the (') in the middle 
>> of the string. How do I properly get around this problem?
>>     
>
> You can use any quoting mechanism you like:
>
> ...("This is a programmer's ...")
> ...(q@This is a programmer's ...@)
> etc.
>
>   


Sorry for the Perl question.
Is the "q" in "(q@This is a programmer's ...@)" a typo?


>> Also, M::SA->check_message_text('This too\') is a problem too because of 
>>     
> [...]
>   
>> Any ideas on the best way to handle this?
>>     
>
> Well, SA won't help you with general Perl quoting, just so we're clear this
> isn't SA specific.  You could read the string into a variable then pass the
> variable, or use one of the above methods, or something like:
> $variable = <<EOF;
> This is a programmer's ...
> blah
> foo bar
> EOF
> ...check_message_text($variable);
>
>   

I'm embedding this is C, so I have a level of C string escaping I have 
to deal with too, besides not being a Perl programmer.
And, that's the crux of the original problem and question.

Joe





Re: finish() method on the status objects

Posted by Theo Van Dinter <fe...@apache.org>.
On Wed, Oct 25, 2006 at 12:57:52PM -0400, Joe Flowers wrote:
> I'd prefer to use M::SA->check_message_text(), but if I do a 
> M::SA->check_message_text('This is a programmer's nightmare.'), then 
> M::SA->check_message_text() will choke because of the (') in the middle 
> of the string. How do I properly get around this problem?

You can use any quoting mechanism you like:

...("This is a programmer's ...")
...(q@This is a programmer's ...@)
etc.

> Also, M::SA->check_message_text('This too\') is a problem too because of 
[...]
> Any ideas on the best way to handle this?

Well, SA won't help you with general Perl quoting, just so we're clear this
isn't SA specific.  You could read the string into a variable then pass the
variable, or use one of the above methods, or something like:
$variable = <<EOF;
This is a programmer's ...
blah
foo bar
EOF
...check_message_text($variable);

-- 
Randomly Selected Tagline:
Q: Don't you know who our President is?
 A: A working class man who started out with nothing in life but two strong
    hands and a brain, and now has to make due with just the hands.
         - http://slashdot.org/comments.pl?sid=189485&cid=15602732

Re: finish() method on the status objects

Posted by Joe Flowers <fl...@social.chass.ncsu.edu>.
Theo Van Dinter wrote:
> You may also want to
> look at M::SA->check_message_text().
>
>   

Theo,

I'd prefer to use M::SA->check_message_text(), but if I do a 
M::SA->check_message_text('This is a programmer's nightmare.'), then 
M::SA->check_message_text() will choke because of the (') in the middle 
of the string. How do I properly get around this problem?

Also, M::SA->check_message_text('This too\') is a problem too because of 
the (\) escapes the final ('), as does M::SA->check_message_text('This 
too\\\').

Any ideas on the best way to handle this?

Joe