Fix incorrect decoding of query string
QueryString class decodes incorrectly when it encounters
percent-encoded query strings "%xy", and cause the http
request class to have wrong query parameters. Fixed a bug
in the process of converting 2-digit hexadecimal number
to a single byte.
Tested:
- Generate requests contains percent-encoded query strings
- Check the urlParams field in crow::Request class and it
works as expected
Example:
- Before:
GET https://{bmc}/...?a=b%20c&d=e
req->urlParams: [ a=b, d=e ]
- After:
GET https://{bmc}/...?a=b%20c&d=e
req->urlParams: [ a=b c, d=e ]
Signed-off-by: Chanyoung Park <park910113@gmail.com>
Change-Id: Ic1bfc74bbf4882e55445dba246ca769699fab332
diff --git a/http/query_string.h b/http/query_string.h
index 6fed49a..e980280 100644
--- a/http/query_string.h
+++ b/http/query_string.h
@@ -203,7 +203,7 @@
qs[i] = '\0';
return i;
}
- qs[i] = static_cast<char>(BMCWEB_QS_HEX2DEC(qs[j + 1] * 16) +
+ qs[i] = static_cast<char>((BMCWEB_QS_HEX2DEC(qs[j + 1]) * 16) +
BMCWEB_QS_HEX2DEC(qs[j + 2]));
j += 2;
}