commit d8b5831dc4f0666dceef671f47d23b5447b25912 (tree)
parent f49a8c5431509bdcff75522a31c3ef637e504380
Author: Chris Boesch <48591413+chrboesch@users.noreply.github.com>
Date: Tue, 26 Dec 2023 16:30:44 +0100
Fixed verbatim copy of trailing '%' in unescapeStr
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/lib/std/Uri.zig b/lib/std/Uri.zig
@@ -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" {