| ... | @@ -1059,8 +1059,16 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 { | ... | @@ -1059,8 +1059,16 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 { |
| 1059 | /// https://url.spec.whatwg.org/#concept-domain-to-ascii | 1059 | /// https://url.spec.whatwg.org/#concept-domain-to-ascii |
| 1060 | // TODO: | 1060 | // TODO: |
| 1061 | fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 { | 1061 | fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 { |
| 1062 | _ = beStrict; | 1062 | const result = try allocator.dupe(u8, domain); |
| 1063 | return allocator.dupe(u8, domain); | 1063 | errdefer allocator.free(result); |
| | 1064 | if (!beStrict) { |
| | 1065 | if (result.len == 0) return error.InvalidURL; |
| | 1066 | if (extras.matchesAny(u8, result, is_forbidden_domain_codepoint)) return error.InvalidURL; |
| | 1067 | return result; |
| | 1068 | } |
| | 1069 | std.debug.assert(result.len > 0); |
| | 1070 | std.debug.assert(!extras.matchesAny(u8, result, is_forbidden_domain_codepoint)); |
| | 1071 | return result; |
| 1064 | } | 1072 | } |
| 1065 | | 1073 | |
| 1066 | // https://url.spec.whatwg.org/#ends-in-a-number-checker | 1074 | // https://url.spec.whatwg.org/#ends-in-a-number-checker |
| ... | @@ -1227,6 +1235,14 @@ fn is_forbidden_host_codepoint(c: u8) bool { | ... | @@ -1227,6 +1235,14 @@ fn is_forbidden_host_codepoint(c: u8) bool { |
| 1227 | if (c == '|') return true; | 1235 | if (c == '|') return true; |
| 1228 | return false; | 1236 | return false; |
| 1229 | } | 1237 | } |
| | 1238 | /// https://url.spec.whatwg.org/#forbidden-domain-code-point |
| | 1239 | fn is_forbidden_domain_codepoint(c: u8) bool { |
| | 1240 | if (is_forbidden_host_codepoint(c)) return true; |
| | 1241 | if (is_c0control(c)) return true; |
| | 1242 | if (c == '%') return true; |
| | 1243 | if (c == 0x7f) return true; |
| | 1244 | return false; |
| | 1245 | } |
| 1230 | /// https://url.spec.whatwg.org/#url-code-points | 1246 | /// https://url.spec.whatwg.org/#url-code-points |
| 1231 | fn is_url_codepoint(c: u21) bool { | 1247 | fn is_url_codepoint(c: u21) bool { |
| 1232 | if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true; | 1248 | if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true; |