File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,6 @@ struct msg_data {
91
91
char * data ;
92
92
int len ;
93
93
unsigned char flags ;
94
- unsigned int crlf :1 ;
95
94
};
96
95
97
96
static const char imap_send_usage [] = "git imap-send < <mbox>" ;
@@ -1166,6 +1165,44 @@ static int imap_make_flags(int flags, char *buf)
1166
1165
return d ;
1167
1166
}
1168
1167
1168
+ static void lf_to_crlf (struct msg_data * msg )
1169
+ {
1170
+ char * new ;
1171
+ int i , j , lfnum = 0 ;
1172
+
1173
+ if (msg -> data [0 ] == '\n' )
1174
+ lfnum ++ ;
1175
+ for (i = 1 ; i < msg -> len ; i ++ ) {
1176
+ if (msg -> data [i - 1 ] != '\r' && msg -> data [i ] == '\n' )
1177
+ lfnum ++ ;
1178
+ }
1179
+
1180
+ new = xmalloc (msg -> len + lfnum );
1181
+ if (msg -> data [0 ] == '\n' ) {
1182
+ new [0 ] = '\r' ;
1183
+ new [1 ] = '\n' ;
1184
+ i = 1 ;
1185
+ j = 2 ;
1186
+ } else {
1187
+ new [0 ] = msg -> data [0 ];
1188
+ i = 1 ;
1189
+ j = 1 ;
1190
+ }
1191
+ for ( ; i < msg -> len ; i ++ ) {
1192
+ if (msg -> data [i ] != '\n' ) {
1193
+ new [j ++ ] = msg -> data [i ];
1194
+ continue ;
1195
+ }
1196
+ if (msg -> data [i - 1 ] != '\r' )
1197
+ new [j ++ ] = '\r' ;
1198
+ /* otherwise it already had CR before */
1199
+ new [j ++ ] = '\n' ;
1200
+ }
1201
+ msg -> len += lfnum ;
1202
+ free (msg -> data );
1203
+ msg -> data = new ;
1204
+ }
1205
+
1169
1206
static int imap_store_msg (struct store * gctx , struct msg_data * data )
1170
1207
{
1171
1208
struct imap_store * ctx = (struct imap_store * )gctx ;
@@ -1175,6 +1212,7 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data)
1175
1212
int ret , d ;
1176
1213
char flagstr [128 ];
1177
1214
1215
+ lf_to_crlf (data );
1178
1216
memset (& cb , 0 , sizeof (cb ));
1179
1217
1180
1218
cb .dlen = data -> len ;
You can’t perform that action at this time.
0 commit comments