(imap_string): Bugfix. Handle numbers in the input
Showing
1 changed file
with
27 additions
and
2 deletions
... | @@ -44,6 +44,7 @@ | ... | @@ -44,6 +44,7 @@ |
44 | #include <mailutils/attribute.h> | 44 | #include <mailutils/attribute.h> |
45 | #include <mailutils/debug.h> | 45 | #include <mailutils/debug.h> |
46 | #include <mailutils/error.h> | 46 | #include <mailutils/error.h> |
47 | #include <mailutils/errno.h> | ||
47 | #include <mailutils/header.h> | 48 | #include <mailutils/header.h> |
48 | #include <mailutils/observer.h> | 49 | #include <mailutils/observer.h> |
49 | #include <mailutils/stream.h> | 50 | #include <mailutils/stream.h> |
... | @@ -1071,6 +1072,24 @@ imap_quoted_string (f_imap_t f_imap, char **ptr) | ... | @@ -1071,6 +1072,24 @@ imap_quoted_string (f_imap_t f_imap, char **ptr) |
1071 | return 0; | 1072 | return 0; |
1072 | } | 1073 | } |
1073 | 1074 | ||
1075 | /* A number consists of one or more digit characters, and represents a | ||
1076 | numeric value. */ | ||
1077 | |||
1078 | static int | ||
1079 | imap_digits (f_imap_t f_imap, char **ptr) | ||
1080 | { | ||
1081 | char *start = *ptr; | ||
1082 | int len; | ||
1083 | |||
1084 | for (++*ptr; **ptr && isdigit(**ptr); ++*ptr) | ||
1085 | ; | ||
1086 | len = *ptr - start; | ||
1087 | stream_write (f_imap->string.stream, start, len, | ||
1088 | f_imap->string.offset, NULL); | ||
1089 | f_imap->string.offset += len; | ||
1090 | return 0; | ||
1091 | } | ||
1092 | |||
1074 | /* Find which type of string the response is: literal or quoted and let the | 1093 | /* Find which type of string the response is: literal or quoted and let the |
1075 | function fill the string buffer. */ | 1094 | function fill the string buffer. */ |
1076 | static int | 1095 | static int |
... | @@ -1093,9 +1112,11 @@ imap_string (f_imap_t f_imap, char **ptr) | ... | @@ -1093,9 +1112,11 @@ imap_string (f_imap_t f_imap, char **ptr) |
1093 | status = imap_literal_string (f_imap, ptr); | 1112 | status = imap_literal_string (f_imap, ptr); |
1094 | } | 1113 | } |
1095 | break; | 1114 | break; |
1115 | |||
1096 | case '"': | 1116 | case '"': |
1097 | status = imap_quoted_string (f_imap, ptr); | 1117 | status = imap_quoted_string (f_imap, ptr); |
1098 | break; | 1118 | break; |
1119 | |||
1099 | /* NIL */ | 1120 | /* NIL */ |
1100 | case 'N': | 1121 | case 'N': |
1101 | case 'n': | 1122 | case 'n': |
... | @@ -1103,9 +1124,13 @@ imap_string (f_imap_t f_imap, char **ptr) | ... | @@ -1103,9 +1124,13 @@ imap_string (f_imap_t f_imap, char **ptr) |
1103 | (*ptr)++; /* I|i */ | 1124 | (*ptr)++; /* I|i */ |
1104 | (*ptr)++; /* L|l */ | 1125 | (*ptr)++; /* L|l */ |
1105 | break; | 1126 | break; |
1127 | |||
1106 | default: | 1128 | default: |
1107 | /* Problem. */ | 1129 | if (isdigit (**ptr)) |
1108 | status = 1; | 1130 | status = imap_digits (f_imap, ptr); |
1131 | else | ||
1132 | /* Problem. FIXME: Return a more appropriate error code */ | ||
1133 | status = MU_ERR_FAILURE; | ||
1109 | break; | 1134 | break; |
1110 | } | 1135 | } |
1111 | return status; | 1136 | return status; | ... | ... |
-
Please register or sign in to post a comment