This commit is contained in:
Jarred Sumner
2023-11-14 00:55:19 -08:00
parent a9a68c3143
commit 89c76f2b45
2 changed files with 15 additions and 7 deletions

View File

@@ -5026,3 +5026,14 @@ pub const URLFormatter = struct {
}
}
};
pub fn mustEscapeYAMLString(contents: []const u8) bool {
if (contents.len == 0) return true;
return switch (contents[0]) {
'A'...'Z', 'a'...'z' => strings.hasPrefixComptime(contents, "Yes") or strings.hasPrefixComptime(contents, "No") or strings.hasPrefixComptime(contents, "true") or
strings.hasPrefixComptime(contents, "false") or
std.mem.indexOfAnyPos(u8, contents, 1, ": \t\r\n\x0B\x0C\\\",[]") != null,
else => true,
};
}