return -1;
}
-/* Escapes '.', '/' and '%' in identifier to %hex */
+/* Escapes '/' and '%' in identifier to %hex */
static const char *escape_identifier(const char *identifier)
{
- size_t pos = strcspn(identifier, "./%");
+ size_t pos = strcspn(identifier, "/%");
/* nothing to escape */
if (identifier[pos] == '\0')
return identifier;
for (size_t i = pos; i < len; i++) {
switch (identifier[i]) {
- case '.':
- str_append(new_id, "%2e");
- break;
case '/':
str_append(new_id, "%2f");
break;
"http://test.unit/local%key",
"hs256",
"http://test.unit/local%key",
- "http:%2f%2ftest%2eunit%2flocal%25key",
- "http:%2f%2ftest%2eunit%2flocal%25key"
+ "http:%2f%2ftest.unit%2flocal%25key",
+ "http:%2f%2ftest.unit%2flocal%25key"
},
- { "../", "hs256", "../", "%2e%2e%2f", "%2e%2e%2f" },
+ { "../", "hs256", "../", "..%2f", "..%2f" },
};
test_begin("JWT token escaping");
random_fill(ptr, 32);
buffer_t *b64_key = t_base64_encode(0, SIZE_MAX,
secret->data, secret->used);
- save_key_to("HS256", "hello%2eworld%2f%25", str_c(b64_key));
+ save_key_to("HS256", "hello.world%2f%25", str_c(b64_key));
/* make a token */
buffer_t *tokenbuf = create_jwt_token_kid("HS256", "hello.world/%");
/* sign it */