Skip to content

A local video studio for your coding agent. Describe a video in one sentence: your agent directs, your machine renders. Claude Code, Codex, Cursor, Devin and more. No API keys, no uploads.

showtime 0.4.5: an events file with a NUL byte is refused on every platform

Favio Vázquez4c20ee5163f1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ac209ad..6150bf6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,7 +15,7 @@ All notable changes to showtime. Each entry says what changed and why, so this f
gives the frame rate and length and lets `xray verify` check the film. The live page's commands then start with
`xray import`. A film made this way used to need a hand-written `xray.json`. Limits: an events file up to 50 MB and
100,000 events, film times up to 24 h; a file it cannot hold (NaN or infinity, a huge number, deep nesting, an
- over-long CSV cell) is refused with the reason, before a job exists. `--strength` with a cell that is not a number
+ over-long CSV cell, a file with a NUL byte (one saved as UTF-16, say)) is refused with the reason, before a job exists. `--strength` with a cell that is not a number
is refused (a blank cell is strength 0, counted in one warning); `--time-map ",5"` sets T0 alone, and a part given
twice is refused. The note it writes names the events file, never a folder. A data column named `kind`, `ch`,
`notes` or `pitches` can no longer break the live page.
diff --git a/skills/showtime/lib/st/xray.py b/skills/showtime/lib/st/xray.py
index 39a5259..223cbad 100644
--- a/skills/showtime/lib/st/xray.py
+++ b/skills/showtime/lib/st/xray.py
@@ -516,6 +516,17 @@ def read_event_rows(path: Path) -> Tuple[List[Dict[str, Any]], List[str]]:
if size > MAX_EVENTS_BYTES:
raise ShowtimeError("%s is %.0f MB; an events file may be up to %d MB" % (path.name, size / 1048576.0, MAX_EVENTS_BYTES // 1048576),
hint="keep the events you want in the film (peaks, not the whole signal)")
+ with open(path, "rb") as raw: # a NUL byte: csv reads it on some Pythons and drops the row on others
+ at = 0
+ while True:
+ chunk = raw.read(1048576)
+ if not chunk:
+ break
+ k = chunk.find(b"\x00")
+ if k >= 0:
+ raise ShowtimeError("%s has a NUL byte (at byte %d)" % (path.name, at + k),
+ hint="save it as plain UTF-8 text (a file saved as UTF-16 has one in every character)")
+ at += len(chunk)
with open(path, encoding="utf-8-sig") as f:
first = f.read(4096)
as_json = path.suffix.lower() == ".json" or first.lstrip()[:1] in ("[", "{")
diff --git a/skills/showtime/tests/test_xray.py b/skills/showtime/tests/test_xray.py
index 44336bf..c3b724c 100644
--- a/skills/showtime/tests/test_xray.py
+++ b/skills/showtime/tests/test_xray.py
@@ -1179,11 +1179,10 @@ class ReaderLimits(unittest.TestCase):
def test_a_csv_cell_the_reader_cannot_take_is_a_refusal(self):
self.refused(self.f("wide.csv", "t,note\n1," + "x" * 140000 + "\n"), "cannot read wide.csv as a CSV file")
- try:
- rows = xray.read_event_rows(self.f("nul.csv", "t,note\n1,a\x00b\n"))[0] # Python 3.11+ reads a NUL
- self.assertEqual(len(rows), 1)
- except ShowtimeError as e:
- self.assertIn("as a CSV file", str(e))
+ self.refused(self.f("nul.csv", "t,note\n1,a\x00b\n"), "NUL byte") # the same on every platform and Python
+ u16 = Path(self.f("u16.csv", "")); u16.write_bytes("t\n1\n".encode("utf-16"))
+ self.refused(u16, "NUL byte")
+ self.refused(u16, "UTF-16")
def test_a_first_row_with_a_huge_number_is_not_a_header(self):
self.refused(self.f("big1.csv", "1" * 400 + ",2\n0.5,3\n"), "too large to hold")