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>" ;
@@ -1162,6 +1161,44 @@ static int imap_make_flags(int flags, char *buf)
1162
1161
return d ;
1163
1162
}
1164
1163
1164
+ static void lf_to_crlf (struct msg_data * msg )
1165
+ {
1166
+ char * new ;
1167
+ int i , j , lfnum = 0 ;
1168
+
1169
+ if (msg -> data [0 ] == '\n' )
1170
+ lfnum ++ ;
1171
+ for (i = 1 ; i < msg -> len ; i ++ ) {
1172
+ if (msg -> data [i - 1 ] != '\r' && msg -> data [i ] == '\n' )
1173
+ lfnum ++ ;
1174
+ }
1175
+
1176
+ new = xmalloc (msg -> len + lfnum );
1177
+ if (msg -> data [0 ] == '\n' ) {
1178
+ new [0 ] = '\r' ;
1179
+ new [1 ] = '\n' ;
1180
+ i = 1 ;
1181
+ j = 2 ;
1182
+ } else {
1183
+ new [0 ] = msg -> data [0 ];
1184
+ i = 1 ;
1185
+ j = 1 ;
1186
+ }
1187
+ for ( ; i < msg -> len ; i ++ ) {
1188
+ if (msg -> data [i ] != '\n' ) {
1189
+ new [j ++ ] = msg -> data [i ];
1190
+ continue ;
1191
+ }
1192
+ if (msg -> data [i - 1 ] != '\r' )
1193
+ new [j ++ ] = '\r' ;
1194
+ /* otherwise it already had CR before */
1195
+ new [j ++ ] = '\n' ;
1196
+ }
1197
+ msg -> len += lfnum ;
1198
+ free (msg -> data );
1199
+ msg -> data = new ;
1200
+ }
1201
+
1165
1202
static int imap_store_msg (struct store * gctx , struct msg_data * data )
1166
1203
{
1167
1204
struct imap_store * ctx = (struct imap_store * )gctx ;
@@ -1171,6 +1208,7 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data)
1171
1208
int ret , d ;
1172
1209
char flagstr [128 ];
1173
1210
1211
+ lf_to_crlf (data );
1174
1212
memset (& cb , 0 , sizeof (cb ));
1175
1213
1176
1214
cb .dlen = data -> len ;
You can’t perform that action at this time.
0 commit comments