This seems to be a backwards compatibility issue with Mail::IMAPClient. Looking at ->search, it always calls ->_quote_search to quote its arguments. And ->_quote_search passes through everything unchanged if it receives only one argument except the object.
This makes passing only one unquoted argument to ->search inconvenient.
I used the following code to play around with this:
>perl -MData::Dumper -MMail::IMAPClient -we "print Dumper [@ARGV], Mai +l::IMAPClient->_quote_search(@ARGV)" "1 \"2\" foo" 3 $VAR1 = [ '1 "2" foo', '3' ]; $VAR2 = '{9} 1 "2" foo'; $VAR3 = '3'; >perl -MData::Dumper -MMail::IMAPClient -we "print Dumper [@ARGV], Mai +l::IMAPClient->_quote_search(@ARGV)" "\"2\" foo" $VAR1 = [ '"2" foo' ]; $VAR2 = '"2" foo';
So ideally, if you want to search only for the SUBJECT attribute, you can split up your query arguments into the two strings SUBJECT and the actual, unquoted target string. That should trigger the appropriate argument quoting in Mail::IMAPClient.
use strict; use Mail::IMAPClient; use Data::Dumper; sub test_quote { print "Parameters: " . Dumper \@_; my @quoted= Mail::IMAPClient->_quote_search(@_); print "Result : " . Dumper \@quoted; }; test_quote( q(SUBJECT "SUBJECT \"test email \"abc123\" approved\")); test_quote( SUBJECT => q(test email "abc123" approved) ); __END__ Parameters: $VAR1 = [ 'SUBJECT "SUBJECT \\"test email \\"abc123\\" approved\\"' ]; Result : $VAR1 = [ 'SUBJECT "SUBJECT \\"test email \\"abc123\\" approved\\"' ]; Parameters: $VAR1 = [ 'SUBJECT', 'test email "abc123" approved' ]; Result : $VAR1 = [ 'SUBJECT', '{28} test email "abc123" approved' ];
(Maybe your assumption was that IMAP quoting works like shell quoting?)
In reply to Re: Mail::IMAPClient and searching email subjects with double quotes
by Corion
in thread Mail::IMAPClient and searching email subjects with double quotes
by treize
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |