Fixed verbatim copy of trailing '%' in unescapeStr

This commit is contained in:
Chris Boesch 2023-12-26 16:30:44 +01:00 committed by Andrew Kelley
parent f49a8c5431
commit d8b5831dc4

View File

@ -90,6 +90,8 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out
};
inptr += 2;
outsize += 1;
} else {
outsize += 1;
}
} else {
inptr += 1;
@ -116,6 +118,9 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out
inptr += 2;
outptr += 1;
} else {
output[outptr] = input[inptr - 1];
outptr += 1;
}
} else {
output[outptr] = input[inptr];
@ -758,6 +763,10 @@ test "URI unescaping" {
defer std.testing.allocator.free(actual);
try std.testing.expectEqualSlices(u8, expected, actual);
const decoded = try unescapeString(std.testing.allocator, "/abc%");
defer std.testing.allocator.free(decoded);
try std.testing.expectEqualStrings("/abc%", decoded);
}
test "URI query escaping" {