Skip to content

Commit bdd456f

Browse files
authored
Merge pull request #2491 from willmafh/improve-code-readability
more clean validateCookieString function to improve code readability
2 parents b83cd92 + 2f66edc commit bdd456f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/browser/webapi/storage/Cookie.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,10 @@ fn validateCookieString(str: []const u8) ValidateCookieError!void {
240240

241241
// Invalid if (c < 32 AND c != 9) OR c > 126. Tab is the one
242242
// sub-space byte we allow through (per browser/WPT behavior).
243-
const below = @intFromBool(chunk < space) & @intFromBool(chunk != tab);
244-
const above = @intFromBool(chunk > tilde);
245-
const reduced: std.meta.Int(.unsigned, size) = @bitCast(below | above);
243+
const is_invalid = ((chunk < space) & (chunk != tab)) | (chunk > tilde);
246244

247245
// Got match.
248-
if (reduced != 0) {
246+
if (@reduce(.Or, is_invalid)) {
249247
return error.InvalidByteSequence;
250248
}
251249
}

0 commit comments

Comments
 (0)