Show 50 hidden lines
- # Tectonic opens any path the TeX source names, including absolute and- # ``..`` paths, even with --untrusted. Untrusted sources are therefore- # rendered only when every file reference is a literal relative path inside- # the staging directory. Commands below either build control sequences or- # file names indirectly (so a path cannot be checked from the source text),- # or read or write files; any occurrence skips rendering. The list covers the- # TeX primitives and common packages, not every package in the bundle.- _UNSAFE_CONTROL_WORDS = frozenset(- {- # Indirect control sequences, catcodes and character codes- "catcode", "lccode", "uccode", "lowercase", "uppercase", "csname",- "endcsname", "ifcsname", "scantokens", "primitive", "makeatletter",- "ExplSyntaxOn", "ExplSyntaxNamesOn", "ProvidesExplPackage",- "ProvidesExplClass", "ProvidesExplFile", "UseName", "ExpandArgs",- "csuse", "csdef", "csgdef", "csedef", "csxdef", "cslet", "csletcs",- "letcs", "csexpandonce",- # Primitive file access- "openin", "read", "readline", "openout", "special", "XeTeXpicfile",- "XeTeXpdffile", "directlua",- # Package commands that read, embed or write files- "IfFileExists", "InputIfFileExists", "lstinputlisting", "VerbatimInput",- "BVerbatimInput", "LVerbatimInput", "verbatiminput", "inputminted",- "pgfplotstableread", "pgfplotstabletypeset", "pgfplotstablesave",- "CatchFileDef", "CatchFileEdef", "CatchFileBGroup", "csvreader",- "csvloop", "csvautotabular", "csvautobooktabular", "csvautolongtable",- "DTLloaddb", "DTLloadrawdb", "import", "subimport", "inputfrom",- "includefrom", "subinputfrom", "subincludefrom", "includestandalone",- "includesvg", "includepdf", "includeinkscape", "bibliography",- "addbibresource", "externaldocument", "tikzexternalize", "pgfimage",- "pgfdeclareimage", "readdef", "readarray", "embedfile", "attachfile",- "textattachfile", "filecontents",- }- ) # fmt: skip- # Commands whose braced argument names a file that is staged or looked up.- _PATH_CONTROL_WORDS = frozenset({"input", "include", "includegraphics"})- # Commands whose braced argument names packages, classes, libraries or- # directories.- _NAME_LIST_CONTROL_WORDS = frozenset(- {- "usepackage", "RequirePackage", "documentclass", "LoadClass",- "usetikzlibrary", "usepgflibrary", "usepgfplotslibrary", "graphicspath",- }- ) # fmt: skip- _CONTROL_SEQUENCE_PATTERN = re.compile(r"\\(?:([A-Za-z]+)|.)", re.DOTALL)- _OPTIONAL_ARGUMENT_PATTERN = re.compile(r"\s*(?:\[(?:[^\[\]]|\[[^\[\]]*\])*\])?\s*")- _SAFE_RELATIVE_PATH_PATTERN = re.compile(r"[A-Za-z0-9_][A-Za-z0-9_. /-]*")- # pgfplots/TikZ keys and plot operations that read data files.- _DATA_FILE_KEY_PATTERN = re.compile(- r"search\s+path|read\s+from\s+file|(?<![A-Za-z\\])file\s*(?:\[[^\]]*\])?\s*\{"+ # Best-effort pre-check for untrusted sources: skip rendering when the
This AI-co-authored change removes the broad unsafe-control-word block that explicitly covered verbatiminput and lstinputlisting. The remaining deny-list is narrower and lets those file-reading commands reach Tectonic, which can read files the process can access.