authorgravatar for 48591413+chrboesch@users.noreply.github.comChris Boesch <48591413+chrboesch@users.noreply.github.com> 2023-12-26 16:30:44+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-12 16:20:44-08:00
logd8b5831dc4f0666dceef671f47d23b5447b25912
tree554c967a907ba718d542e40d9dfc4f2e59bdbdf2
parentf49a8c5431509bdcff75522a31c3ef637e504380

Fixed verbatim copy of trailing '%' in unescapeStr


1 files changed, 9 insertions(+), 0 deletions(-)

lib/std/Uri.zig+9
......@@ -90,6 +90,8 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out
9090 };
9191 inptr += 2;
9292 outsize += 1;
93 } else {
94 outsize += 1;
9395 }
9496 } else {
9597 inptr += 1;
......@@ -116,6 +118,9 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out
116118
117119 inptr += 2;
118120 outptr += 1;
121 } else {
122 output[outptr] = input[inptr - 1];
123 outptr += 1;
119124 }
120125 } else {
121126 output[outptr] = input[inptr];
......@@ -758,6 +763,10 @@ test "URI unescaping" {
758763 defer std.testing.allocator.free(actual);
759764
760765 try std.testing.expectEqualSlices(u8, expected, actual);
766
767 const decoded = try unescapeString(std.testing.allocator, "/abc%");
768 defer std.testing.allocator.free(decoded);
769 try std.testing.expectEqualStrings("/abc%", decoded);
761770}
762771
763772test "URI query escaping" {