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