diff options
-rw-r--r-- | src/main.zig | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig index 3ee70cc..a299afe 100644 --- a/src/main.zig +++ b/src/main.zig | |||
@@ -390,7 +390,7 @@ pub fn areKeySectionContentsValid(contents: []const u8) bool { | |||
390 | return true; | 390 | return true; |
391 | } | 391 | } |
392 | 392 | ||
393 | pub fn findKeySection(text: []const u8, line_it: *std.mem.SplitIterator) ?[]const u8 { | 393 | pub fn findKeySection(line_it: *std.mem.SplitIterator) ?[]const u8 { |
394 | while (true) { | 394 | while (true) { |
395 | const opening_line = line_it.next() orelse return null; | 395 | const opening_line = line_it.next() orelse return null; |
396 | if (!isKeySectionBarrier(opening_line, true)) continue; | 396 | if (!isKeySectionBarrier(opening_line, true)) continue; |
@@ -407,15 +407,14 @@ pub fn findKeySection(text: []const u8, line_it: *std.mem.SplitIterator) ?[]cons | |||
407 | 407 | ||
408 | pub fn parseDecoratedJwt(contents: []const u8) []const u8 { | 408 | pub fn parseDecoratedJwt(contents: []const u8) []const u8 { |
409 | var line_it = mem.split(contents, "\n"); | 409 | var line_it = mem.split(contents, "\n"); |
410 | return findKeySection(contents, &line_it) orelse return contents; | 410 | return findKeySection(&line_it) orelse return contents; |
411 | } | 411 | } |
412 | 412 | ||
413 | pub fn parseDecoratedNkey(contents: []const u8) NoNkeySeedFoundError!SeedKeyPair { | 413 | pub fn parseDecoratedNkey(contents: []const u8) NoNkeySeedFoundError!SeedKeyPair { |
414 | var line_it = mem.split(contents, "\n"); | 414 | var line_it = mem.split(contents, "\n"); |
415 | var current_off: usize = 0; | ||
416 | var seed: ?[]const u8 = null; | 415 | var seed: ?[]const u8 = null; |
417 | if (findKeySection(contents, &line_it) != null) | 416 | if (findKeySection(&line_it) != null) |
418 | seed = findKeySection(contents, &line_it); | 417 | seed = findKeySection(&line_it); |
419 | if (seed == null) | 418 | if (seed == null) |
420 | seed = findNkey(contents) orelse return error.NoNkeySeedFound; | 419 | seed = findNkey(contents) orelse return error.NoNkeySeedFound; |
421 | if (!isValidCredsNkey(seed.?)) | 420 | if (!isValidCredsNkey(seed.?)) |
@@ -441,7 +440,6 @@ fn isValidCredsNkey(text: []const u8) bool { | |||
441 | 440 | ||
442 | fn findNkey(text: []const u8) ?[]const u8 { | 441 | fn findNkey(text: []const u8) ?[]const u8 { |
443 | var line_it = std.mem.split(text, "\n"); | 442 | var line_it = std.mem.split(text, "\n"); |
444 | var current_off: usize = 0; | ||
445 | while (line_it.next()) |line| { | 443 | while (line_it.next()) |line| { |
446 | for (line) |c, i| { | 444 | for (line) |c, i| { |
447 | if (!ascii.isSpace(c)) { | 445 | if (!ascii.isSpace(c)) { |