| ... | ... | @@ -0,0 +1,512 @@ |
| 1 | //! Implements URI parsing roughly adhering to <https://tools.ietf.org/html/rfc3986>. |
| 2 | //! Does not do perfect grammar and character class checking, but should be robust against URIs in the wild. |
| 3 | |
| 4 | const Uri = @This(); |
| 5 | const std = @import("std.zig"); |
| 6 | const testing = std.testing; |
| 7 | |
| 8 | scheme: []const u8, |
| 9 | user: ?[]const u8, |
| 10 | password: ?[]const u8, |
| 11 | host: ?[]const u8, |
| 12 | port: ?u16, |
| 13 | path: []const u8, |
| 14 | query: ?[]const u8, |
| 15 | fragment: ?[]const u8, |
| 16 | |
| 17 | /// Applies URI encoding and replaces all reserved characters with their respective %XX code. |
| 18 | pub fn escapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]const u8 { |
| 19 | var outsize: usize = 0; |
| 20 | for (input) |c| { |
| 21 | outsize += if (isUnreserved(c)) @as(usize, 1) else 3; |
| 22 | } |
| 23 | var output = try allocator.alloc(u8, outsize); |
| 24 | var outptr: usize = 0; |
| 25 | |
| 26 | for (input) |c| { |
| 27 | if (isUnreserved(c)) { |
| 28 | output[outptr] = c; |
| 29 | outptr += 1; |
| 30 | } else { |
| 31 | var buf: [2]u8 = undefined; |
| 32 | _ = std.fmt.bufPrint(&buf, "{X:0>2}", .{c}) catch unreachable; |
| 33 | |
| 34 | output[outptr + 0] = '%'; |
| 35 | output[outptr + 1] = buf[0]; |
| 36 | output[outptr + 2] = buf[1]; |
| 37 | outptr += 3; |
| 38 | } |
| 39 | } |
| 40 | return output; |
| 41 | } |
| 42 | |
| 43 | /// Parses a URI string and unescapes all %XX where XX is a valid hex number. Otherwise, verbatim copies |
| 44 | /// them to the output. |
| 45 | pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]const u8 { |
| 46 | var outsize: usize = 0; |
| 47 | var inptr: usize = 0; |
| 48 | while (inptr < input.len) { |
| 49 | if (input[inptr] == '%') { |
| 50 | inptr += 1; |
| 51 | if (inptr + 2 <= input.len) { |
| 52 | _ = std.fmt.parseInt(u8, input[inptr..][0..2], 16) catch { |
| 53 | outsize += 3; |
| 54 | inptr += 2; |
| 55 | continue; |
| 56 | }; |
| 57 | inptr += 2; |
| 58 | outsize += 1; |
| 59 | } |
| 60 | } else { |
| 61 | inptr += 1; |
| 62 | outsize += 1; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | var output = try allocator.alloc(u8, outsize); |
| 67 | var outptr: usize = 0; |
| 68 | inptr = 0; |
| 69 | while (inptr < input.len) { |
| 70 | if (input[inptr] == '%') { |
| 71 | inptr += 1; |
| 72 | if (inptr + 2 <= input.len) { |
| 73 | const value = std.fmt.parseInt(u8, input[inptr..][0..2], 16) catch { |
| 74 | output[outptr + 0] = input[inptr + 0]; |
| 75 | output[outptr + 1] = input[inptr + 1]; |
| 76 | inptr += 2; |
| 77 | outptr += 2; |
| 78 | continue; |
| 79 | }; |
| 80 | |
| 81 | output[outptr] = value; |
| 82 | |
| 83 | inptr += 2; |
| 84 | outptr += 1; |
| 85 | } |
| 86 | } else { |
| 87 | output[outptr] = input[inptr]; |
| 88 | inptr += 1; |
| 89 | outptr += 1; |
| 90 | } |
| 91 | } |
| 92 | return output; |
| 93 | } |
| 94 | |
| 95 | pub const ParseError = error{ UnexpectedCharacter, InvalidFormat, InvalidPort }; |
| 96 | |
| 97 | /// Parses the URI or returns an error. |
| 98 | /// The return value will contain unescaped strings pointing into the |
| 99 | /// original `text`. Each component that is provided, will be non-`null`. |
| 100 | pub fn parse(text: []const u8) ParseError!Uri { |
| 101 | var reader = SliceReader{ .slice = text }; |
| 102 | var uri = Uri{ |
| 103 | .scheme = reader.readWhile(isSchemeChar), |
| 104 | .user = null, |
| 105 | .password = null, |
| 106 | .host = null, |
| 107 | .port = null, |
| 108 | .path = "", // path is always set, but empty by default. |
| 109 | .query = null, |
| 110 | .fragment = null, |
| 111 | }; |
| 112 | |
| 113 | // after the scheme, a ':' must appear |
| 114 | if (reader.get()) |c| { |
| 115 | if (c != ':') |
| 116 | return error.UnexpectedCharacter; |
| 117 | } else { |
| 118 | return error.InvalidFormat; |
| 119 | } |
| 120 | |
| 121 | if (reader.peekPrefix("//")) { // authority part |
| 122 | std.debug.assert(reader.get().? == '/'); |
| 123 | std.debug.assert(reader.get().? == '/'); |
| 124 | |
| 125 | const authority = reader.readUntil(isAuthoritySeparator); |
| 126 | if (authority.len == 0) |
| 127 | return error.InvalidFormat; |
| 128 | |
| 129 | var start_of_host: usize = 0; |
| 130 | if (std.mem.indexOf(u8, authority, "@")) |index| { |
| 131 | start_of_host = index + 1; |
| 132 | const user_info = authority[0..index]; |
| 133 | |
| 134 | if (std.mem.indexOf(u8, user_info, ":")) |idx| { |
| 135 | uri.user = user_info[0..idx]; |
| 136 | if (idx < user_info.len - 1) { // empty password is also "no password" |
| 137 | uri.password = user_info[idx + 1 ..]; |
| 138 | } |
| 139 | } else { |
| 140 | uri.user = user_info; |
| 141 | uri.password = null; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | var end_of_host: usize = authority.len; |
| 146 | |
| 147 | if (authority[start_of_host] == '[') { // IPv6 |
| 148 | end_of_host = std.mem.lastIndexOf(u8, authority, "]") orelse return error.InvalidFormat; |
| 149 | end_of_host += 1; |
| 150 | |
| 151 | if (std.mem.lastIndexOf(u8, authority, ":")) |index| { |
| 152 | if (index >= end_of_host) { // if not part of the V6 address field |
| 153 | end_of_host = std.math.min(end_of_host, index); |
| 154 | uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort; |
| 155 | } |
| 156 | } |
| 157 | } else if (std.mem.lastIndexOf(u8, authority, ":")) |index| { |
| 158 | if (index >= start_of_host) { // if not part of the userinfo field |
| 159 | end_of_host = std.math.min(end_of_host, index); |
| 160 | uri.port = std.fmt.parseInt(u16, authority[index + 1 ..], 10) catch return error.InvalidPort; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | uri.host = authority[start_of_host..end_of_host]; |
| 165 | } |
| 166 | |
| 167 | uri.path = reader.readUntil(isPathSeparator); |
| 168 | |
| 169 | if ((reader.peek() orelse 0) == '?') { // query part |
| 170 | std.debug.assert(reader.get().? == '?'); |
| 171 | uri.query = reader.readUntil(isQuerySeparator); |
| 172 | } |
| 173 | |
| 174 | if ((reader.peek() orelse 0) == '#') { // fragment part |
| 175 | std.debug.assert(reader.get().? == '#'); |
| 176 | uri.fragment = reader.readUntilEof(); |
| 177 | } |
| 178 | |
| 179 | return uri; |
| 180 | } |
| 181 | |
| 182 | const SliceReader = struct { |
| 183 | const Self = @This(); |
| 184 | |
| 185 | slice: []const u8, |
| 186 | offset: usize = 0, |
| 187 | |
| 188 | fn get(self: *Self) ?u8 { |
| 189 | if (self.offset >= self.slice.len) |
| 190 | return null; |
| 191 | const c = self.slice[self.offset]; |
| 192 | self.offset += 1; |
| 193 | return c; |
| 194 | } |
| 195 | |
| 196 | fn peek(self: Self) ?u8 { |
| 197 | if (self.offset >= self.slice.len) |
| 198 | return null; |
| 199 | return self.slice[self.offset]; |
| 200 | } |
| 201 | |
| 202 | fn readWhile(self: *Self, comptime predicate: fn (u8) bool) []const u8 { |
| 203 | const start = self.offset; |
| 204 | var end = start; |
| 205 | while (end < self.slice.len and predicate(self.slice[end])) { |
| 206 | end += 1; |
| 207 | } |
| 208 | self.offset = end; |
| 209 | return self.slice[start..end]; |
| 210 | } |
| 211 | |
| 212 | fn readUntil(self: *Self, comptime predicate: fn (u8) bool) []const u8 { |
| 213 | const start = self.offset; |
| 214 | var end = start; |
| 215 | while (end < self.slice.len and !predicate(self.slice[end])) { |
| 216 | end += 1; |
| 217 | } |
| 218 | self.offset = end; |
| 219 | return self.slice[start..end]; |
| 220 | } |
| 221 | |
| 222 | fn readUntilEof(self: *Self) []const u8 { |
| 223 | const start = self.offset; |
| 224 | self.offset = self.slice.len; |
| 225 | return self.slice[start..]; |
| 226 | } |
| 227 | |
| 228 | fn peekPrefix(self: Self, prefix: []const u8) bool { |
| 229 | if (self.offset + prefix.len > self.slice.len) |
| 230 | return false; |
| 231 | return std.mem.eql(u8, self.slice[self.offset..][0..prefix.len], prefix); |
| 232 | } |
| 233 | }; |
| 234 | |
| 235 | /// scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) |
| 236 | fn isSchemeChar(c: u8) bool { |
| 237 | return switch (c) { |
| 238 | 'A'...'Z', 'a'...'z', '0'...'9', '+', '-', '.' => true, |
| 239 | else => false, |
| 240 | }; |
| 241 | } |
| 242 | |
| 243 | fn isAuthoritySeparator(c: u8) bool { |
| 244 | return switch (c) { |
| 245 | '/', '?', '#' => true, |
| 246 | else => false, |
| 247 | }; |
| 248 | } |
| 249 | |
| 250 | /// reserved = gen-delims / sub-delims |
| 251 | fn isReserved(c: u8) bool { |
| 252 | return isGenLimit(c) or isSubLimit(c); |
| 253 | } |
| 254 | |
| 255 | /// gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" |
| 256 | fn isGenLimit(c: u8) bool { |
| 257 | return switch (c) { |
| 258 | ':', ',', '?', '#', '[', ']', '@' => true, |
| 259 | else => false, |
| 260 | }; |
| 261 | } |
| 262 | |
| 263 | /// sub-delims = "!" / "$" / "&" / "'" / "(" / ")" |
| 264 | /// / "*" / "+" / "," / ";" / "=" |
| 265 | fn isSubLimit(c: u8) bool { |
| 266 | return switch (c) { |
| 267 | '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' => true, |
| 268 | else => false, |
| 269 | }; |
| 270 | } |
| 271 | |
| 272 | /// unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" |
| 273 | fn isUnreserved(c: u8) bool { |
| 274 | return switch (c) { |
| 275 | 'A'...'Z', 'a'...'z', '0'...'9', '-', '.', '_', '~' => true, |
| 276 | else => false, |
| 277 | }; |
| 278 | } |
| 279 | |
| 280 | fn isPathSeparator(c: u8) bool { |
| 281 | return switch (c) { |
| 282 | '?', '#' => true, |
| 283 | else => false, |
| 284 | }; |
| 285 | } |
| 286 | |
| 287 | fn isQuerySeparator(c: u8) bool { |
| 288 | return switch (c) { |
| 289 | '#' => true, |
| 290 | else => false, |
| 291 | }; |
| 292 | } |
| 293 | |
| 294 | test "basic" { |
| 295 | const parsed = try parse("https://ziglang.org/download"); |
| 296 | try testing.expectEqualStrings("https", parsed.scheme); |
| 297 | try testing.expectEqualStrings("ziglang.org", parsed.host orelse return error.UnexpectedNull); |
| 298 | try testing.expectEqualStrings("/download", parsed.path); |
| 299 | try testing.expectEqual(@as(?u16, null), parsed.port); |
| 300 | } |
| 301 | |
| 302 | test "with port" { |
| 303 | const parsed = try parse("http://example:1337/"); |
| 304 | try testing.expectEqualStrings("http", parsed.scheme); |
| 305 | try testing.expectEqualStrings("example", parsed.host orelse return error.UnexpectedNull); |
| 306 | try testing.expectEqualStrings("/", parsed.path); |
| 307 | try testing.expectEqual(@as(?u16, 1337), parsed.port); |
| 308 | } |
| 309 | |
| 310 | test "should fail gracefully" { |
| 311 | try std.testing.expectEqual(@as(ParseError!Uri, error.InvalidFormat), parse("foobar://")); |
| 312 | } |
| 313 | |
| 314 | test "scheme" { |
| 315 | try std.testing.expectEqualSlices(u8, "http", (try parse("http:_")).scheme); |
| 316 | try std.testing.expectEqualSlices(u8, "scheme-mee", (try parse("scheme-mee:_")).scheme); |
| 317 | try std.testing.expectEqualSlices(u8, "a.b.c", (try parse("a.b.c:_")).scheme); |
| 318 | try std.testing.expectEqualSlices(u8, "ab+", (try parse("ab+:_")).scheme); |
| 319 | try std.testing.expectEqualSlices(u8, "X+++", (try parse("X+++:_")).scheme); |
| 320 | try std.testing.expectEqualSlices(u8, "Y+-.", (try parse("Y+-.:_")).scheme); |
| 321 | } |
| 322 | |
| 323 | test "authority" { |
| 324 | try std.testing.expectEqualSlices(u8, "hostname", (try parse("scheme://hostname")).host.?); |
| 325 | |
| 326 | try std.testing.expectEqualSlices(u8, "hostname", (try parse("scheme://userinfo@hostname")).host.?); |
| 327 | try std.testing.expectEqualSlices(u8, "userinfo", (try parse("scheme://userinfo@hostname")).user.?); |
| 328 | try std.testing.expectEqual(@as(?[]const u8, null), (try parse("scheme://userinfo@hostname")).password); |
| 329 | |
| 330 | try std.testing.expectEqualSlices(u8, "hostname", (try parse("scheme://user:password@hostname")).host.?); |
| 331 | try std.testing.expectEqualSlices(u8, "user", (try parse("scheme://user:password@hostname")).user.?); |
| 332 | try std.testing.expectEqualSlices(u8, "password", (try parse("scheme://user:password@hostname")).password.?); |
| 333 | |
| 334 | try std.testing.expectEqualSlices(u8, "hostname", (try parse("scheme://hostname:0")).host.?); |
| 335 | try std.testing.expectEqual(@as(u16, 1234), (try parse("scheme://hostname:1234")).port.?); |
| 336 | |
| 337 | try std.testing.expectEqualSlices(u8, "hostname", (try parse("scheme://userinfo@hostname:1234")).host.?); |
| 338 | try std.testing.expectEqual(@as(u16, 1234), (try parse("scheme://userinfo@hostname:1234")).port.?); |
| 339 | try std.testing.expectEqualSlices(u8, "userinfo", (try parse("scheme://userinfo@hostname:1234")).user.?); |
| 340 | try std.testing.expectEqual(@as(?[]const u8, null), (try parse("scheme://userinfo@hostname:1234")).password); |
| 341 | |
| 342 | try std.testing.expectEqualSlices(u8, "hostname", (try parse("scheme://user:password@hostname:1234")).host.?); |
| 343 | try std.testing.expectEqual(@as(u16, 1234), (try parse("scheme://user:password@hostname:1234")).port.?); |
| 344 | try std.testing.expectEqualSlices(u8, "user", (try parse("scheme://user:password@hostname:1234")).user.?); |
| 345 | try std.testing.expectEqualSlices(u8, "password", (try parse("scheme://user:password@hostname:1234")).password.?); |
| 346 | } |
| 347 | |
| 348 | test "authority.password" { |
| 349 | try std.testing.expectEqualSlices(u8, "username", (try parse("scheme://username@a")).user.?); |
| 350 | try std.testing.expectEqual(@as(?[]const u8, null), (try parse("scheme://username@a")).password); |
| 351 | |
| 352 | try std.testing.expectEqualSlices(u8, "username", (try parse("scheme://username:@a")).user.?); |
| 353 | try std.testing.expectEqual(@as(?[]const u8, null), (try parse("scheme://username:@a")).password); |
| 354 | |
| 355 | try std.testing.expectEqualSlices(u8, "username", (try parse("scheme://username:password@a")).user.?); |
| 356 | try std.testing.expectEqualSlices(u8, "password", (try parse("scheme://username:password@a")).password.?); |
| 357 | |
| 358 | try std.testing.expectEqualSlices(u8, "username", (try parse("scheme://username::@a")).user.?); |
| 359 | try std.testing.expectEqualSlices(u8, ":", (try parse("scheme://username::@a")).password.?); |
| 360 | } |
| 361 | |
| 362 | fn testAuthorityHost(comptime hostlist: anytype) !void { |
| 363 | inline for (hostlist) |hostname| { |
| 364 | try std.testing.expectEqualSlices(u8, hostname, (try parse("scheme://" ++ hostname)).host.?); |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | test "authority.dns-names" { |
| 369 | try testAuthorityHost(.{ |
| 370 | "a", |
| 371 | "a.b", |
| 372 | "example.com", |
| 373 | "www.example.com", |
| 374 | "example.org.", |
| 375 | "www.example.org.", |
| 376 | "xn--nw2a.xn--j6w193g", // internationalized URI: 見.香港 |
| 377 | "fe80--1ff-fe23-4567-890as3.ipv6-literal.net", |
| 378 | }); |
| 379 | } |
| 380 | |
| 381 | test "authority.IPv4" { |
| 382 | try testAuthorityHost(.{ |
| 383 | "127.0.0.1", |
| 384 | "255.255.255.255", |
| 385 | "0.0.0.0", |
| 386 | "8.8.8.8", |
| 387 | "1.2.3.4", |
| 388 | "192.168.0.1", |
| 389 | "10.42.0.0", |
| 390 | }); |
| 391 | } |
| 392 | |
| 393 | test "authority.IPv6" { |
| 394 | try testAuthorityHost(.{ |
| 395 | "[2001:db8:0:0:0:0:2:1]", |
| 396 | "[2001:db8::2:1]", |
| 397 | "[2001:db8:0000:1:1:1:1:1]", |
| 398 | "[2001:db8:0:1:1:1:1:1]", |
| 399 | "[0:0:0:0:0:0:0:0]", |
| 400 | "[0:0:0:0:0:0:0:1]", |
| 401 | "[::1]", |
| 402 | "[::]", |
| 403 | "[2001:db8:85a3:8d3:1319:8a2e:370:7348]", |
| 404 | "[fe80::1ff:fe23:4567:890a%25eth2]", |
| 405 | "[fe80::1ff:fe23:4567:890a]", |
| 406 | "[fe80::1ff:fe23:4567:890a%253]", |
| 407 | "[fe80:3::1ff:fe23:4567:890a]", |
| 408 | }); |
| 409 | } |
| 410 | |
| 411 | test "RFC example 1" { |
| 412 | const uri = "foo://example.com:8042/over/there?name=ferret#nose"; |
| 413 | try std.testing.expectEqual(Uri{ |
| 414 | .scheme = uri[0..3], |
| 415 | .user = null, |
| 416 | .password = null, |
| 417 | .host = uri[6..17], |
| 418 | .port = 8042, |
| 419 | .path = uri[22..33], |
| 420 | .query = uri[34..45], |
| 421 | .fragment = uri[46..50], |
| 422 | }, try parse(uri)); |
| 423 | } |
| 424 | |
| 425 | test "RFX example 2" { |
| 426 | const uri = "urn:example:animal:ferret:nose"; |
| 427 | try std.testing.expectEqual(Uri{ |
| 428 | .scheme = uri[0..3], |
| 429 | .user = null, |
| 430 | .password = null, |
| 431 | .host = null, |
| 432 | .port = null, |
| 433 | .path = uri[4..], |
| 434 | .query = null, |
| 435 | .fragment = null, |
| 436 | }, try parse(uri)); |
| 437 | } |
| 438 | |
| 439 | // source: |
| 440 | // https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Examples |
| 441 | test "Examples from wikipedia" { |
| 442 | const list = [_][]const u8{ |
| 443 | "https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top", |
| 444 | "ldap://[2001:db8::7]/c=GB?objectClass?one", |
| 445 | "mailto:John.Doe@example.com", |
| 446 | "news:comp.infosystems.www.servers.unix", |
| 447 | "tel:+1-816-555-1212", |
| 448 | "telnet://192.0.2.16:80/", |
| 449 | "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", |
| 450 | "http://a/b/c/d;p?q", |
| 451 | }; |
| 452 | for (list) |uri| { |
| 453 | _ = try parse(uri); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | // source: |
| 458 | // https://tools.ietf.org/html/rfc3986#section-5.4.1 |
| 459 | test "Examples from RFC3986" { |
| 460 | const list = [_][]const u8{ |
| 461 | "http://a/b/c/g", |
| 462 | "http://a/b/c/g", |
| 463 | "http://a/b/c/g/", |
| 464 | "http://a/g", |
| 465 | "http://g", |
| 466 | "http://a/b/c/d;p?y", |
| 467 | "http://a/b/c/g?y", |
| 468 | "http://a/b/c/d;p?q#s", |
| 469 | "http://a/b/c/g#s", |
| 470 | "http://a/b/c/g?y#s", |
| 471 | "http://a/b/c/;x", |
| 472 | "http://a/b/c/g;x", |
| 473 | "http://a/b/c/g;x?y#s", |
| 474 | "http://a/b/c/d;p?q", |
| 475 | "http://a/b/c/", |
| 476 | "http://a/b/c/", |
| 477 | "http://a/b/", |
| 478 | "http://a/b/", |
| 479 | "http://a/b/g", |
| 480 | "http://a/", |
| 481 | "http://a/", |
| 482 | "http://a/g", |
| 483 | }; |
| 484 | for (list) |uri| { |
| 485 | _ = try parse(uri); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | test "Special test" { |
| 490 | // This is for all of you code readers ♥ |
| 491 | _ = try parse("https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be&t=0"); |
| 492 | } |
| 493 | |
| 494 | test "URI escaping" { |
| 495 | const input = "\\ö/ äöß ~~.adas-https://canvas:123/#ads&&sad"; |
| 496 | const expected = "%5C%C3%B6%2F%20%C3%A4%C3%B6%C3%9F%20~~.adas-https%3A%2F%2Fcanvas%3A123%2F%23ads%26%26sad"; |
| 497 | |
| 498 | const actual = try escapeString(std.testing.allocator, input); |
| 499 | defer std.testing.allocator.free(actual); |
| 500 | |
| 501 | try std.testing.expectEqualSlices(u8, expected, actual); |
| 502 | } |
| 503 | |
| 504 | test "URI unescaping" { |
| 505 | const input = "%5C%C3%B6%2F%20%C3%A4%C3%B6%C3%9F%20~~.adas-https%3A%2F%2Fcanvas%3A123%2F%23ads%26%26sad"; |
| 506 | const expected = "\\ö/ äöß ~~.adas-https://canvas:123/#ads&&sad"; |
| 507 | |
| 508 | const actual = try unescapeString(std.testing.allocator, input); |
| 509 | defer std.testing.allocator.free(actual); |
| 510 | |
| 511 | try std.testing.expectEqualSlices(u8, expected, actual); |
| 512 | } |