MCO_RET mco_lews_url_param_decode(
char *in_str,
mco_size_t in_size,
char *out_str,
mco_size_t out_size
);
in_str
"bar%20foo").in_size
out_str
out_size
This function decodes a URL-encoded (percent-encoded) string according to RFC 3986.
It scans the input for sequences of the form
%XX, whereXXis a two-digit hexadecimal number, and replaces each such sequence with the corresponding byte (e.g.,%20→ space character0x20).Invalid percent-encodings (e.g.,
%2z,%1) are treated as literal characters and copied as-is.The output string is null-terminated.
MCO_RET rc; char tmp_buf[1024]; lews_connection_context_t ctx; ... /* // Incoming buffer contains: "GET /some?param1=AbC¶m2=bar%20foo¶m3=123¶m4=bar%2zzz¶m5=qqq HTTP/1.1\r\n" "Host: example.com\r\n" "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n\r\n" */ rc = mco_lews_get_query_param_str((char*)(&ctx.incoming_buf) + ctx.params_pos, ctx.params_len, "param2", tmp_buf, sizeof(tmp_buf)); ASSERT_EQ(MCO_S_OK, rc); ASSERT_STREQ("bar%20foo", tmp_buf); rc = mco_lews_url_param_decode(tmp_buf, strlen(tmp_buf), tmp_buf, sizeof(tmp_buf)); ASSERT_EQ(MCO_S_OK, rc); ASSERT_STREQ("bar foo", tmp_buf);
MCO_S_OK
out_str.MCO_E_LEWS_NO_ENOUGH_MEMORY
MCO_E_LEWS_BAD_PARAMETERS
in_str or out_str) are NULL.