mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
kittygfx: Ensure temporary files are named per spec
Temporary files used with Kitty graphics must have "tty-graphics-protocol" somewhere in their full path. https://sw.kovidgoyal.net/kitty/graphics-protocol/#the-transmission-medium
This commit is contained in:
@ -382,6 +382,7 @@ fn encodeError(r: *Response, err: EncodeableError) void {
|
|||||||
error.DecompressionFailed => r.message = "EINVAL: decompression failed",
|
error.DecompressionFailed => r.message = "EINVAL: decompression failed",
|
||||||
error.FilePathTooLong => r.message = "EINVAL: file path too long",
|
error.FilePathTooLong => r.message = "EINVAL: file path too long",
|
||||||
error.TemporaryFileNotInTempDir => r.message = "EINVAL: temporary file not in temp dir",
|
error.TemporaryFileNotInTempDir => r.message = "EINVAL: temporary file not in temp dir",
|
||||||
|
error.TemporaryFileNotNamedCorrectly => r.message = "EINVAL: temporary file not named correctly",
|
||||||
error.UnsupportedFormat => r.message = "EINVAL: unsupported format",
|
error.UnsupportedFormat => r.message = "EINVAL: unsupported format",
|
||||||
error.UnsupportedMedium => r.message = "EINVAL: unsupported medium",
|
error.UnsupportedMedium => r.message = "EINVAL: unsupported medium",
|
||||||
error.UnsupportedDepth => r.message = "EINVAL: unsupported pixel depth",
|
error.UnsupportedDepth => r.message = "EINVAL: unsupported pixel depth",
|
||||||
|
@ -220,6 +220,9 @@ pub const LoadingImage = struct {
|
|||||||
// Temporary file logic
|
// Temporary file logic
|
||||||
if (medium == .temporary_file) {
|
if (medium == .temporary_file) {
|
||||||
if (!isPathInTempDir(path)) return error.TemporaryFileNotInTempDir;
|
if (!isPathInTempDir(path)) return error.TemporaryFileNotInTempDir;
|
||||||
|
if (std.mem.indexOf(u8, path, "tty-graphics-protocol") == null) {
|
||||||
|
return error.TemporaryFileNotNamedCorrectly;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
defer if (medium == .temporary_file) {
|
defer if (medium == .temporary_file) {
|
||||||
posix.unlink(path) catch |err| {
|
posix.unlink(path) catch |err| {
|
||||||
@ -469,6 +472,7 @@ pub const Image = struct {
|
|||||||
DimensionsTooLarge,
|
DimensionsTooLarge,
|
||||||
FilePathTooLong,
|
FilePathTooLong,
|
||||||
TemporaryFileNotInTempDir,
|
TemporaryFileNotInTempDir,
|
||||||
|
TemporaryFileNotNamedCorrectly,
|
||||||
UnsupportedFormat,
|
UnsupportedFormat,
|
||||||
UnsupportedMedium,
|
UnsupportedMedium,
|
||||||
UnsupportedDepth,
|
UnsupportedDepth,
|
||||||
|
Reference in New Issue
Block a user