Commit 9c6d4837 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos
Browse files

io-http2: do not try make header name/value valid UTF-8

nghttp2 already ensures they don't have any invalid character.
parent 8c59b364
Pipeline #286260 passed with stages
in 5 minutes and 16 seconds
......@@ -317,13 +317,8 @@ on_header_callback (nghttp2_session *session,
return 0;
}
// FIXME: Encoding
char *name_utf8 = g_utf8_make_valid ((const char *)name, namelen);
char *value_utf8 = g_utf8_make_valid ((const char *)value, valuelen);
soup_message_headers_append (soup_message_get_response_headers (data->msg),
name_utf8, value_utf8);
g_free (name_utf8);
g_free (value_utf8);
(const char *)name, (const char *)value);
return 0;
}
......
  • nghttp2 does nothing regarding encoding, it just ensures its a valid header.

    libsoup passing around non-utf8 strings is dangerous...

  • nghttp2 checks every character in name and vale are valid. The spec doesn't say headers should utf8, and we don't do anyting about that in http1 either. If we really want to do anything I think it should be done in SoupHeader for both http1 and http2 and not there. But I think we should give the user what we got from the network and they should handle it.

  • But I think we should give the user what we got from the network and they should handle it.

    I don't agree with that. I think all strings in our API should be validated UTF-8.

    If we really want to do anything I think it should be done in SoupHeader for both http1 and http2 and not there.

    Agreed.

  • I agree with all strings being valid UTF-8 as a general rule, but there are exceptions like filenames and I think this should be another one.

  • Filenames being a different encoding is a problem, and for example every API assuming that has to have a custom GI annotation otherwise many language bindings explode when they receive non-UTF-8.

    If we want to return bytes the API should return guint8* and we should have a UTF-8 variant.

    Edited by Patrick Griffis
  • That's a good point.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment