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...@@ -90,6 +90,8 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out
90 };90 };
91 inptr += 2;91 inptr += 2;
92 outsize += 1;92 outsize += 1;
93 } else {
94 outsize += 1;
93 }95 }
94 } else {96 } else {
95 inptr += 1;97 inptr += 1;
...@@ -116,6 +118,9 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out...@@ -116,6 +118,9 @@ pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{Out
116118
117 inptr += 2;119 inptr += 2;
118 outptr += 1;120 outptr += 1;
121 } else {
122 output[outptr] = input[inptr - 1];
123 outptr += 1;
119 }124 }
120 } else {125 } else {
121 output[outptr] = input[inptr];126 output[outptr] = input[inptr];
...@@ -758,6 +763,10 @@ test "URI unescaping" {...@@ -758,6 +763,10 @@ test "URI unescaping" {
758 defer std.testing.allocator.free(actual);763 defer std.testing.allocator.free(actual);
759764
760 try std.testing.expectEqualSlices(u8, expected, actual);765 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);
761}770}
762771
763test "URI query escaping" {772test "URI query escaping" {