~whynothugo/pimsync#32: 
libdav: non-utf8 encoding

Some servers might use non-utf8.

Status
REPORTED
Submitter
~whynothugo
Assigned to
No-one
Submitted
1 year, 9 months ago
Updated
24 days ago
Labels
0:missing-feature 3:libdav after-v1

~whynothugo 1 year, 9 months ago

This quick hack helps detect any that aren't. I haven't found any non-utf8 servers so far.

if let Some(content_type) = head.headers.get("content-type") {
            // TODO: write a proper parser for content types.
            let content_type = std::str::from_utf8(content_type.as_bytes()).unwrap();
            let content_type = content_type.to_lowercase();
            let found = content_type.contains("charset=\"utf-8\"")
                || content_type.contains("charset=utf-8");
            if !found {
                warn!("Response does not seem to be utf-8. Content Type: {content_type}",);
            }
        };

~whynothugo 1 year, 9 months ago

I should probably set the Accept header too: https://www.rfc-editor.org/rfc/rfc9110#field.accept

~whynothugo 1 year, 9 months ago

Register here or Log in to comment, or comment via email.