imap: fix regexps

modern-harvey3
Doug Coleman 2019-12-24 14:40:38 -05:00
parent d934114fb7
commit 0b6c3f6f8e
1 changed files with 7 additions and 7 deletions

View File

@ -48,9 +48,9 @@ CONSTANT: IMAP4_SSL_PORT 993
: read-response-chunk ( stop-expr -- item ? ) : read-response-chunk ( stop-expr -- item ? )
read-?crlf ascii decode swap dupd pcre:findall read-?crlf ascii decode swap dupd pcre:findall
[ [
dup [[ ^.*{(\d+)}$]] pcre:findall dup [[^.*{(\d+)}$]] pcre:findall
[ [
dup [[ ^\* (\d+) [A-Z-]+ (.*)$]] pcre:findall dup [[^\* (\d+) [A-Z-]+ (.*)$]] pcre:findall
[ ] [ nip first third second ] if-empty [ ] [ nip first third second ] if-empty
] ]
[ [
@ -82,24 +82,24 @@ CONSTANT: IMAP4_SSL_PORT 993
first " " split 2 tail ; first " " split 2 tail ;
: parse-list-folders ( str -- folder ) : parse-list-folders ( str -- folder )
[[ \* LIST \(([^\)]+)\) "([^"]+)" "?([^"]+)"?]] pcre:findall [[\* LIST \(([^\)]+)\) "([^"]+)" "?([^"]+)"?]] pcre:findall
first rest values [ utf7imap4 decode ] map ; first rest values [ utf7imap4 decode ] map ;
: parse-select-folder ( seq -- count ) : parse-select-folder ( seq -- count )
[ [[ \* (\d+) EXISTS]] pcre:findall ] map harvest [ [[\* (\d+) EXISTS]] pcre:findall ] map harvest
[ f ] [ first first last last string>number ] if-empty ; [ f ] [ first first last last string>number ] if-empty ;
! Returns uid if the server supports the UIDPLUS extension. ! Returns uid if the server supports the UIDPLUS extension.
: parse-append-mail ( seq -- uid/f ) : parse-append-mail ( seq -- uid/f )
[ [=[ \[APPENDUID (\d+) \d+\]]=] pcre:findall ] map harvest [ [=[\[APPENDUID (\d+) \d+\]]=] pcre:findall ] map harvest
[ f ] [ first first last last string>number ] if-empty ; [ f ] [ first first last last string>number ] if-empty ;
: parse-status ( seq -- assoc ) : parse-status ( seq -- assoc )
first [[ \* STATUS "[^"]+" \(([^\)]+)\)]] pcre:findall first last last first [[\* STATUS "[^"]+" \(([^\)]+)\)]] pcre:findall first last last
" " split 2 group [ string>number ] assoc-map ; " " split 2 group [ string>number ] assoc-map ;
: parse-store-mail-line ( str -- pair/f ) : parse-store-mail-line ( str -- pair/f )
[[ \(FLAGS \(([^\)]+)\) UID (\d+)\)]] pcre:findall [ f ] [ [[\(FLAGS \(([^\)]+)\) UID (\d+)\)]] pcre:findall [ f ] [
first rest values first2 [ " " split ] dip string>number swap 2array first rest values first2 [ " " split ] dip string>number swap 2array
] if-empty ; ] if-empty ;