Subject: | Re: append_string fails to get id from APPEND in more complex answer |
Date: | Sun, 19 Apr 2020 14:35:58 +0000 |
To: | "bug-Mail-IMAPClient [...] rt.cpan.org" <bug-Mail-IMAPClient [...] rt.cpan.org> |
From: | Ing. Radomír Polách <radomirpolach [...] protonmail.com> |
Fix of last line:
my $ret = $data =~ m#\s+(\d+)\s*\]\s+APPEND# ? $1 : $self;
Ing. Radomír Polách
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, April 19, 2020 4:34 PM, Ing. Radomír Polách <radomirpolach@protonmail.com> wrote:
Show quoted text
> I am having answers like these:
>
> 20 APPEND Folders/Test (\Seen) "09-Apr-2020 12:21:44 +0000" {3032}+ send literal
> * 1 EXISTS
> * OK [UNSEEN 0]
> * 1 FETCH (FLAGS (\Seen nonjunk) UID 7)
> 20 OK [APPENDUID 5 7] APPEND successful
>
> This coauses this line:
> my $ret = $data =~ m#\s+(\d+)\]# ? $1 : $self;
> To produce 0 from [UNSEEN 0].
>
> Needs to be replace with a least something like:
> my $ret = $data =~ m#\s+(\d+)\]\s+APPEND# ? $1 : $self;
>
> But I can image more complex answers, for example spaces after id:
> 20 OK [APPENDUID 5 7 ] APPEND successful
>
> So maybe even:
> my $ret = $data =~ m#\s+(\d+)\s+\]\s+APPEND# ? $1 : $self;
>
> The current regular expression is extremely fragile.
>
> Ing. Radomír Polách