about summary refs log tree commit homepage
path: root/lib/PublicInbox/IMAP.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:06 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commita62624ba8aa07f4d38d6d99623f6a2e679193896 (patch)
tree76cafcf4ca6563cfeda08aa2a2af61406a1d967f /lib/PublicInbox/IMAP.pm
parent7952dfc9ba1255400f85068364150bc5e0db869d (diff)
downloadpublic-inbox-a62624ba8aa07f4d38d6d99623f6a2e679193896.tar.gz
IMAP clients may quote args and escape similar to POSIX shell,
so attempt to handle them properly using this standard library
module.
Diffstat (limited to 'lib/PublicInbox/IMAP.pm')
-rw-r--r--lib/PublicInbox/IMAP.pm4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index a2d59e5c..7745d9f9 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -20,6 +20,7 @@ use fields qw(imapd logged_in ibx long_cb -login_tag
 use PublicInbox::Eml;
 use PublicInbox::DS qw(now);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
+use Text::ParseWords qw(parse_line);
 use Errno qw(EAGAIN);
 my $Address;
 for my $mod (qw(Email::Address::XS Mail::Address)) {
@@ -423,7 +424,8 @@ sub args_ok ($$) { # duplicated from PublicInbox::NNTP
 # returns 1 if we can continue, 0 if not due to buffered writes or disconnect
 sub process_line ($$) {
         my ($self, $l) = @_;
-        my ($tag, $req, @args) = split(/[ \t]+/, $l);
+        my ($tag, $req, @args) = parse_line('[ \t]+', 0, $l);
+        pop(@args) if (@args && !defined($args[-1]));
         if (@args && uc($req) eq 'UID') {
                 $req .= "_".(shift @args);
         }