dc_mimeparser_parse: accept input as slice, not as pointer + length

This commit is contained in:
Dmitry Bogatov
2019-08-26 16:58:31 +00:00
committed by Floris Bruynooghe
parent d3048aa06f
commit 21976b14a6
3 changed files with 7 additions and 12 deletions

View File

@@ -659,11 +659,9 @@ fn test_dc_mimeparser_with_context() {
let context = create_test_context();
let mut mimeparser = dc_mimeparser_new(&context.ctx);
let raw: *const libc::c_char =
b"Content-Type: multipart/mixed; boundary=\"==break==\";\nSubject: outer-subject\nX-Special-A: special-a\nFoo: Bar\nChat-Version: 0.0\n\n--==break==\nContent-Type: text/plain; protected-headers=\"v1\";\nSubject: inner-subject\nX-Special-B: special-b\nFoo: Xy\nChat-Version: 1.0\n\ntest1\n\n--==break==--\n\n\x00"
as *const u8 as *const libc::c_char;
let raw = b"Content-Type: multipart/mixed; boundary=\"==break==\";\nSubject: outer-subject\nX-Special-A: special-a\nFoo: Bar\nChat-Version: 0.0\n\n--==break==\nContent-Type: text/plain; protected-headers=\"v1\";\nSubject: inner-subject\nX-Special-B: special-b\nFoo: Xy\nChat-Version: 1.0\n\ntest1\n\n--==break==--\n\n\x00";
dc_mimeparser_parse(&mut mimeparser, raw, strlen(raw));
dc_mimeparser_parse(&mut mimeparser, &raw[..]);
assert_eq!(
as_str(mimeparser.subject as *const libc::c_char),
"inner-subject",