summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristófer R <kristofer@thorlaksson.com>2025-04-30 23:54:42 -0400
committerKristófer R <kristofer@thorlaksson.com>2025-06-07 22:07:17 -0400
commit19ca1bfb1ca950bd7ddcb58718903bafc7777944 (patch)
tree05f859a64716808e7f5a1950b60c6d8f8d1e0f9f
parent0e74b8027aef60e9b8bf600ee1f88b03463661f8 (diff)
Fix modulo operation and custom Uri struct init
-rw-r--r--src/termio/stream_handler.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/termio/stream_handler.zig b/src/termio/stream_handler.zig
index 5327d8b36..6668b17cd 100644
--- a/src/termio/stream_handler.zig
+++ b/src/termio/stream_handler.zig
@@ -1082,17 +1082,18 @@ pub const StreamHandler = struct {
// address are non-digits, e.g. 'ff', and thus an invalid port.
//
// Example: file://12:34:56:78:90:12/path/to/file
+ if (e != error.InvalidPort) return;
// Insufficient length to have a mac address in the hostname.
if (url.len < 24) {
- log.warn("invalid url in OSC 7: {}", .{e});
+ log.warn("invalid MAC address in OSC 7: insufficient length", .{});
return;
}
// The first '/' after the scheme marks the end of the hostname. If the hostname is
// not 17 characters, it's not a mac address.
if (std.mem.indexOfScalarPos(u8, url, 7, '/') != 24) {
- log.warn("invalid url in OSC 7: {}", .{e});
+ log.warn("invalid MAC address in OSC 7: invalid scheme", .{});
return;
}
@@ -1102,14 +1103,14 @@ pub const StreamHandler = struct {
for (0..mac_address.len) |i| {
const c = mac_address[i];
- if (i + 1 % 3 == 0) {
+ if ((i + 1) % 3 == 0) {
if (c != ':') {
- log.warn("invalid url in OSC 7: {}", .{e});
+ log.warn("invalid MAC address in OSC 7: missing colon", .{});
return;
}
} else {
- if (!std.mem.containsAtLeastScalar(u8, "0123456789abcdef", 1, mac_address[i])) {
- log.warn("invalid url in OSC 7: {}", .{e});
+ if (!std.mem.containsAtLeastScalar(u8, "0123456789ABCDEFabcdef", 1, mac_address[i])) {
+ log.warn("invalid MAC address in OSC 7: invalid character '{c}' at position '{d}'", .{ mac_address[i], i });
return;
}
}
@@ -1125,7 +1126,7 @@ pub const StreamHandler = struct {
// Same compliance factor as std.Uri.parse(), i.e. not at all compliant with the URI
// spec.
break :uri .{
- .scheme = "file://",
+ .scheme = "file",
.host = .{ .percent_encoded = mac_address },
.path = .{ .percent_encoded = url[24..uri_path_end_idx] },
};