Commit b405b4bc authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Fix token68 decoding

parent 415b8ed6
......@@ -93,7 +93,9 @@ int main(int argc, char* argv[])
shrpx::test_downstream_get_norm_response_header) ||
!CU_add_test(pSuite, "util_streq", shrpx::test_util_streq) ||
!CU_add_test(pSuite, "util_inp_strlower",
shrpx::test_util_inp_strlower)) {
shrpx::test_util_inp_strlower) ||
!CU_add_test(pSuite, "util_to_base64",
shrpx::test_util_to_base64)) {
CU_cleanup_registry();
return CU_get_error();
}
......
......@@ -283,7 +283,9 @@ void to_base64(std::string& token68str)
break;
}
}
token68str += std::string(4 - token68str.size() % 4, '=');
if(token68str.size() & 0x3) {
token68str.append(4 - (token68str.size() & 0x3), '=');
}
return;
}
......
......@@ -71,4 +71,15 @@ void test_util_inp_strlower(void)
CU_ASSERT("" == a);
}
void test_util_to_base64(void)
{
std::string x = "AAA--B_";
util::to_base64(x);
CU_ASSERT("AAA++B/=" == x);
x = "AAA--B_B";
util::to_base64(x);
CU_ASSERT("AAA++B/B" == x);
}
} // namespace shrpx
......@@ -29,6 +29,7 @@ namespace shrpx {
void test_util_streq(void);
void test_util_inp_strlower(void);
void test_util_to_base64(void);
} // namespace shrpx
......
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