| ... | @@ -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 |
| 116 | | 118 | |
| 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); |
| 759 | | 764 | |
| 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 | } |
| 762 | | 771 | |
| 763 | test "URI query escaping" { | 772 | test "URI query escaping" { |