mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-15 09:18:33 +00:00
Fix bug in splitter
This commit is contained in:
parent
9abac3c5d7
commit
f8947b53ac
3 changed files with 4 additions and 6 deletions
|
@ -285,10 +285,8 @@ jwt_object::three_parts(const string_view enc_str)
|
|||
|
||||
result[1] = string_view{&enc_str[fpos + 1], spos - fpos - 1};
|
||||
|
||||
size_t tpos = enc_str.find_first_of('.', spos + 1);
|
||||
|
||||
if (tpos != string_view::npos) {
|
||||
result[2] = string_view{&enc_str[tpos + 1], tpos - spos - 1};
|
||||
if (spos != enc_str.length()) {
|
||||
result[2] = string_view{&enc_str[spos + 1], enc_str.length() - spos};
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -314,7 +312,7 @@ jwt_object jwt_decode(const string_view encoded_str, const string_view key, bool
|
|||
//length of the encoded header and payload only.
|
||||
//Addition of '1' to account for the '.' character.
|
||||
auto l = parts[0].length() + 1 + parts[1].length();
|
||||
jsign.verify(jobj.header(), encoded_str.substr(0, l), parts[2]);
|
||||
auto res = jsign.verify(jobj.header(), encoded_str.substr(0, l), parts[2]);
|
||||
|
||||
return jobj;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -41,7 +41,7 @@ void basic_jwt_object_test()
|
|||
obj3.secret("secret");
|
||||
obj3.header().algo("hs256");
|
||||
|
||||
std::cout << obj3.signature() << std::endl;
|
||||
auto dec_obj = jwt::jwt_decode(obj3.signature(), "secret");
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue