~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Uploaded documents are now checked and converted through bounded guards before any parser runs. Zip-container uploads (.docx/.xlsx/.pptx/.odt/.epub) are refused when the archive cannot be read; when it does not start at byte 0 (the file must begin with a zip local-header or empty-archive signature and its first entry must sit at offset 0, so a legacy OLE .doc/.ppt with a zip appended, uploaded as .docx/.pptx, can no longer pass the guard and be routed by unstructured to its own unbounded soffice conversion); when a .docx/.pptx/.xlsx has a root mimetype member or member names from which unstructured's zip sniffer would infer another type, when a .docx/.pptx lacks the main document part python-docx/python-pptx resolve through the package relationships, or when an .xlsx has no xl/workbook.xml (langchain's Word and PowerPoint loaders ask unstructured's detect_filetype for the type whenever python-magic imports and send a file it calls DOC or PPT to partition_doc/partition_ppt, which run soffice with no timeout and partition its output without this guard; a zip whose member names match none of the OOXML patterns is typed from its mimetype member, so a 134-byte .docx holding only a mimetype of application/msword was accepted and went there; pandas likewise picks its Excel engine from the member names); when an .odt/.epub mimetype member names another type; when its declared central-directory byte span exceeds the entry-count-scaled bound (10 MiB, read before zipfile walks the records from the end-of-central-directory or ZIP64 end record that zipfile's own end-record lookup selects, so a layout that would show the guard one record and zipfile another cannot slip past, and an archive whose end records zipfile cannot read is refused there: zipfile materialises every central-directory record before the entry count can be counted, and the end record's own entry count wraps at 65,535 and is ignored by zipfile, so a hand-packed record flood a fraction of the upload cap in size bought hundreds of MiB of resident memory before any refusal fired); when it has more than 10,000 entries, encrypted entries, entries sharing one local header, non-canonical or duplicate member names (empty, . or .. path segments, a leading /, backslashes), or entries compressed with anything but STORED or DEFLATE; when an entry's compressed size is inconsistent with its declared size; when an entry declares more than the largest per-entry ceiling; when an entry's local header disagrees with its central-directory record (compression method, flags, CRC, sizes or name, or a data descriptor that does not repeat the central CRC and sizes), since pandoc's zip reader takes an entry's method and compressed size from the local header while the guard and zipfile use the central directory; when a DEFLATE entry does not inflate to exactly its declared size with its declared CRC, its stream ending exactly at the end of its compressed range (every DEFLATE entry is inflated once, in bounded steps, to check; a STORED entry's size is fixed by its equality check and its CRC is checked as well); or when the verified sizes exceed the ceilings: 128 MiB for a parsed (XML/text) part, 512 MiB of parsed parts in total, 512 MiB for a binary media entry in .docx/.pptx/.xlsx (recognised by an anchored binary signature in its leading bytes that no XML parser the in-process loaders use, lxml or expat, accepts as a document start, never by its name; every EPUB/ODT entry stays under the parsed-part ceilings), and 1 GiB across all entries. Each parser read of an entry is therefore bounded by its verified size; parser memory and parser time are not bounded in general (an XML parse tree alone costs roughly 10-20x the XML, and what a loader builds from it can cost far more). python-pptx and python-docx load each media part once, however often it is referenced; .xlsx extraction no longer lets openpyxl read chartsheet drawings (images and charts), which it otherwise re-read once per reference; and an .xlsx workbook whose sheet entries resolve to the same sheet part more than once (which openpyxl would convert once per entry) is refused, as is one whose sheets share a relationships part, with both computed by openpyxl's own workbook reader so the check and the loader cannot disagree (the workbook skeleton parts it parses are held to 16 MiB); a workbook openpyxl cannot resolve is refused as malformed, as is one listing more than 2,000 sheets (openpyxl checks every sheet's target against a list of the members and pandas looks every sheet up in a list of all their names: 10,000 empty sheets took 40 s in pandas.read_excel, and 100,000 sheets without parts next to 9,000 members 7.6 s in openpyxl alone; 2,000 one-cell sheets take about 5 s to partition), and so is one whose xl/styles.xml, which openpyxl loads on every read, has a number format code over 1,024 characters (Excel's own limit is 255), more than 65,490 entries in a cell-format list (Excel's limit on cell formats and styles), or would cost openpyxl more than 4 billion units in the date tests it runs over the format code of every cell format (each counted at the code's length times 50 plus its [ characters, about 0.5 ns per unit, since one scan restarts at every unclosed [: a 3.3 KB workbook with one 1,000,000-character code under 2,000 cell formats took 53 s to load, and 3,600 formats of a 1,024-bracket code, at the ceiling, take 2.1 s) or more than 20 million in the work it repeats once per named style (each named style counted at 600 units, plus the custom formats, whose list openpyxl rebuilds per named style, plus 16 per element and one per 256 characters of the largest font, fill and border, which openpyxl hashes and compares as it binds each named style; a unit is about 130 ns; named styles are counted as the distinct style-format ids they name, up to twice the style formats since openpyxl reads a negative id from the end: 8,800 named styles over 4,400 style formats and 4,400 custom formats took 5.3 s to load, and 1,000 named styles of a 1,000-stop gradient fill, a 13 KB file, about 3 s, while 20,000 named styles of a minimal font, fill and border, at 0.66 of the ceiling, load in 1.8 s, and 15,000 of Excel's default font, fills and border with 300 custom formats, at 0.84, in 2 s). A gradient fill of more than 256 stops (Excel's cell gradients have two or three) is refused too, as is a styles part giving a number format's code or id, a cell format's ids or a named style's fields as child elements, which openpyxl reads in place of the attributes (a 1,881-byte workbook whose 1,000,000-character code was given that way, under 2,000 cell formats, took 52 s to load; 100,000 characters, 5 s); the styles part is streamed once for this, with its lists matched by local name in any namespace as openpyxl matches them. A comment or processing instruction anywhere below the top level of the styles part (inside a list such as fonts or cellXfs, or inside an entry), or of [Content_Types].xml, the workbook part or its relationships, is refused too: openpyxl parses these parts with lxml, which keeps such nodes, and builds a default entry from every child node of the lists fonts, borders, dxfs and mruColors and of the workbook's bookViews (it fails to load one among fills, indexedColors or sheets), while the guard counts elements, so 2,000,000 empty comments after one font, a 25 KB file, were accepted and took openpyxl 37 s and 960 MB to load as 2,000,001 fonts, and 2,390,000 among the bookViews of a 16 MiB workbook part took the guard's own parse of it 19.6 s and 1.1 GB; Excel writes none there. Comments and processing instructions directly under the root element, or outside it, which openpyxl skips, are still accepted, but the .xlsx styles part, .pptx slides, slide layouts and slide masters, and .docx document.xml, headers and footers are refused with more than 64 outside the root element: the guard streams these with comment events, and lxml emits each such event before the root in time linear in the ones before it (60,000 empty comments before a slide's root, a 420 KB part, kept the guard busy for 16.7 s); a .docx with a comment before its document.xml root, which the guard used to refuse as malformed, is accepted. openpyxl also builds an object from every entry of every list of the styles and workbook parts and from every child it knows of every other element, keeping only the last of a repeated one, and nothing bounded most of them: 500,000 <font/> in one differential format, a 10 KB file, took 7.4 s to load, 1,000 fills of 256 gradient stops (a 14 MB part) 4.5 s to load and 8 s in the guard, and 1,800,000 <calcPr/> in a 16 MiB workbook part 17 s in openpyxl and as long again in the guard's own parse. So a styles part is now also refused with more than 256 elements under its root, 8,192 custom number formats (Excel documents 200 to 250), 65,490 differential formats (dxfs, held to Excel's cell-format limit) or 500,000 elements under them, 1,024 custom table styles or 32 elements in one, 1,024 indexed or 1,024 recently used colours, 131,072 extensions (<ext>) in all, or 65,536 gradient stops in all, with every child element of a list counting as an entry and each kind counted over every such list in the part; a workbook part with more than 256 elements under its root, 8,192 entries in any of its view, external reference, pivot cache, smart tag, function group or web publish lists, more than 2,000 entries under sheets (with or without a relationship id) or 131,072 extensions is refused too (the number of defined names stays bounded by the part's 16 MiB ceiling: 250,000 beside every other list at its cap, a 16.4 MB part, take 4.8 s in the guard and 4 s to load); and in both parts an element that is not a list may not repeat a child's local name (Excel never does; the content of an extension, which openpyxl does not read, is exempt, but an extLst that is itself an entry of a list such as fills, or a fill's first child, is read by openpyxl as that entry or as a gradient fill and is counted as one, its stops included), and a styles part with a font, fill, border or cell-format entry of more than 1,024 elements is refused (the guard holds such an entry whole to rebuild it, and lxml takes time quadratic in its nodes to drop it: one fill of 160,000 elements took the guard 6.5 s to drop; a gradient at the 256-stop ceiling has 514). A defined name whose value is longer than 8,192 characters (Excel's formula limit) is refused, the value measured at the longest of the entry's attribute values, its text and its children's text, since openpyxl's from_tree also takes the value from an attr_text or attr-text attribute (a 4.9 KB workbook giving a _xlnm.Print_Area value of 10,000 # that way was accepted and took openpyxl 9.2 s to load), as is a workbook whose print titles and print areas would cost openpyxl more than 67,110,912 units, each counted at its value's length squared plus 2,048: on every load openpyxl parses every sheet-local defined name starting with _xlnm.Print_Titles or _xlnm.Print_Area (a prefix match, so a sheet can hold any number of them) with regular expressions that scan for a sheet name from every position of the value, so 40,000 # characters in one, a file under 2 KB, took 14 to 37 s and a 1 MB value would take hours; one value at the length ceiling, or 31,776 of 8 characters, now takes about 0.9 to 2.9 s. A workbook is also refused when a sheet name is longer than 255 characters (Excel allows 31, Google Sheets 100) or two sheet names are equal once lowercased (Excel forbids it, and openpyxl renames such a chartsheet after joining and searching every sheet name): pandas looks every sheet up by name in lists of all of them, so 2,000 sheets of 8,000-character names, a 554 KB file, took 6.4 s to read; and when an XML part openpyxl's load parses declares a namespace URI longer than 1,024 characters or a DTD: lxml copies the URI into the name of every element under it, which openpyxl reads for every element it parses, so 2,000 empty elements under a 1,000,000-character URI in a worksheet, a 5.9 KB file, took 3.8 s to read. Each part openpyxl's read-only load parses, found as openpyxl finds it ([Content_Types].xml, the workbook part and its relationships, the shared strings the manifest names, the core and custom document properties, the styles part, and every sheet's resolved part and relationships part), is now streamed once before anything parses it, without building a tree, through the parser that load uses for it: lxml for the skeleton, styles, properties, chartsheets and relationships, expat for worksheets and shared strings, and both for [Content_Types].xml, which msoffcrypto reads with minidom. Members nothing parses, such as images, are not read, so a workbook holding an SVG image with the SVG 1.1 DOCTYPE (as Illustrator and icon exports carry) is no longer refused. An expat part is read to its first syntax error, where the loader stops too (libxml2 stops at a name over 50,000 characters, or an attribute value or comment over 10 MB, that expat reads on: a worksheet with a 50,001-character element name before a 1,000,000-character URI used by 5,000 elements, a 5.9 KB file, was accepted by an lxml-only scan and took pandas 4.6 s to read), and an lxml part that lxml fails to parse is refused, since openpyxl's load fails on it too. Such a part is also refused when it is encoded in anything but UTF-8 (an optional UTF-8 byte-order mark, no NUL byte in its first 64 KiB, and no XML declaration or one naming UTF-8): the guard counts a part's < and = in bytes, and the parsers detect UTF-16 differently (expat reads a part whose first or second byte is zero as UTF-16 without a byte-order mark, where libxml2 fails, and libxml2 switches to UTF-16 after an ASCII declaration naming UTF-16LE, which expat rejects), so attribute names whose UTF-16 low byte is < slipped a start tag of 8.66 million attributes past the count and took the guard to 2.25 GB. OPC also allows UTF-16, but every producer surveyed (Excel, Word and PowerPoint, LibreOffice, openpyxl, XlsxWriter, python-docx, python-pptx, SheetJS) writes UTF-8, as do all 2,238 XML members of 88 local Office files, so a UTF-16 part, which openpyxl reads, is now refused too. openpyxl's lxml parse of a buffer also reads UTF-32, which lxml's push parser and expat reject at the first byte, so a UTF-32 docProps/core.xml with a 1,000,000-character URI over 20,000 elements, a 10 KB file, was accepted and took openpyxl 13 s or more to load; when its elements nest more than 256 deep (expat keeps about 145 bytes per open element and lxml's push parser about 36, and neither sets a limit as the scan drives them, so 1,000,000 levels of <a>, an 8 KB file, held 180 MB in the scan, and a 128 MiB part would hold about 8 GB; openpyxl's lxml tree parse stops at 256 itself); when a start tag may carry more than 65,536 attributes (counted as the = between two < before either parser sees the tag; one tag of 1,000,000 attributes, 11 MB, held about 175 MB); or when it uses more than 10,000 distinct element names, attribute names and namespace prefixes, which both parsers keep for the whole parse (1,000,000 distinct element names, 8.9 MB, held about 140 MB). The scan costs the guard about 6.5 s per 100 MB of worksheet XML, a Python call per element for the depth ceiling included (about 4 s before; pandas takes about 20 s to read such a sheet). With every styles list at its ceiling at once (a 51 MB part, 582 KB uploaded) the guard takes 14.5 s and openpyxl 14.6 s and 1.1 GB to load it. A styles part is also refused when it lists more than 8,192 fonts, fills or borders (Excel itself allows 512 fonts per workbook and 256 fill and line styles), when a number openpyxl reads from it is outside 32 bits (an integer below -2,147,483,648 or above 4,294,967,295, or a float of magnitude above 2^32, NaN or infinite; given as an attribute or as the text of a child element of the field's name, which openpyxl reads in place of the attribute even when that child has children of its own), or when more than two distinct style objects of one hash would land in one of the indexed lists openpyxl builds on load (fonts, fills, borders, alignments, protections, cell formats, format codes and named-style names), each entry being rebuilt with openpyxl's own classes to compute it: Python hashes numbers modulo 2^61 - 1, so fonts differing only in a charset of 1 + k(2^61 - 1), or in sizes x and x times 2^-61, are distinct objects of one hash that openpyxl compares with each other on every insertion and again as each named style binds them (4,000 such fonts, a 51 KB part, took 6.6 s to load, and 8,000 under 8,000 named styles 81 s). A 16 MB styles part with every list at these ceilings and 65,490 cell formats, each with its own alignment and protection, loads in about 5 s, and the guard's check of it takes about 10 s. A .pptx listing one slide part under several slide entries (python-pptx yields, and unstructured extracts, a slide once per entry) is refused, as is a .docx with more than 1,000 sections (w:sectPr elements anywhere in document.xml; Word writes one per section break), more than 20,000 rendered page breaks (w:lastRenderedPageBreak elements anywhere in document.xml: unstructured asks once per document whether there are any, with a four-branch union over the body's paragraphs and table cells whose libxml2 merge compares every break with every break of the branches before it, so 96,000 breaks in each of the two table-cell branches, about one text-extraction unit each, were accepted at ~0.9 of the text-extraction ceiling and would take ~18 s for the union alone (extrapolated from 0.77 s for 20,000 each); Word writes one per page in each flow of text a page boundary cuts, so a 1,000-page document of ten-column tables has about 10,000; the pairs are also priced in the text extraction, at 30 ns each, and so is the union's sort, which once a later branch's break precedes an earlier branch's walks the shared parent's children after the breaks: 1,000 breaks of each of two branches in table rows before 160,000 empty table children, a 42 KB file, took 2.2-2.6 s per evaluation and before 640,000, 10.5 s, counted at 0.02 of the text-extraction ceiling before; each element's union breaks times its child nodes, the breaks weighted for libxml2's binary-insertion runs (below 64 nodes, and for a branch's run shorter than its minimum run, it compares each node about log2(n) times: 62 breaks of one branch before one of another walked the filler 12 times per break), is now priced at 150 ns per step, covering siblings that lie a cache miss apart in memory, as filler elements with 16 or more attributes do (35-45 ns per sibling against 3-9 ns for plain ones; 1,000 breaks of each branch before 600,000 such elements, a 386 KB file, were accepted at 0.83 of the text-extraction ceiling at 30 ns per step, and one evaluation took 50 s), with the worst shapes measured at 70-95 ns per weighted step, so the sort costs about 30 s at the ceiling), any relationships part (*.rels member, whether or not the guard follows it to its part: the libraries parse the relationships part of every part they reach) with more than 10,000 entries (comments and processing instructions included) or over 16 MiB, or with an entry that has child elements or an element with more than 64 attributes (the OPC schema gives a relationship four attributes and no child elements; every relationships part, and every other part the guard streams or parses from a .docx or .pptx, is first held to UTF-8 and to start tags of at most 65,536 attributes, counted in its bytes before lxml reads it, since lxml's iterparse builds a start tag in full before any per-element ceiling sees it: one of 2,000,000 attributes in document.xml, 23 MB, held 404 MB in the guard, and a slide's was not refused at all; one entry holding 4 million empty children, a part no library reads that deflates to 16 KB, cost the guard 3.1 s and ~550 MB, and 30 such parts in a 499 KB file 92 s; each part is now streamed holding at most one entry), relationships parts with more than 50,000 entries together, more than 200 million steps of python-docx's relationship walk (internal relationships times members, each member a step plus one per 256 bytes of its name as Python stores it, one, two or four bytes per character by its widest character, since comparing two names reads them that way (names of four-byte characters were counted per character before, a quarter of their cost: 2,000 parts named by 2,000 emoji counted at 0.89 of the ceiling took 9.5 s to open): python-docx scans a list of the parts it has visited once per relationship as it opens a package, so 9,000 parts and one unread part with 200,000 relationships to the last of them, a 1.66 MB file, took 41 s to open; 9,000 parts with 19,000 internal relationships, counted at 0.91 of this ceiling, open in 3 s, and a document with 10,000 images counts about 110 million), or a settings or styles part (each found through the document's relationship of that type, as python-docx finds it) over 16 MiB or with more than 5,000 top-level entries (python-docx and unstructured repeat work once per section and once per paragraph, such as two scans of every document relationship and two searches of the settings part per section, and about four scans of the relationships and of the styles part per non-empty paragraph; rather than model each, these caps keep every such factor small). A .pptx is also refused when its slide placeholders would cost python-pptx's uncached layout and master lookups more than 90,000 units: unstructured reads the top and left of every slide shape up to three times each, and a placeholder without a position of its own inherits it, each read rebuilding the slide's relationships by type and building a proxy for every placeholder of the slide layout up to the matching one (and, when that one has no position either, for the slide master's), so the work is each slide's placeholders times its layout's and master's shapes, plus their shapes' children and grandchildren per 256 and the slide's and layout's relationships per 32 (100 placeholders over a 100-placeholder layout, a 30 KB file, took 5.2 s to partition and 200 over 200 took 18.6 s, quadrupling per doubling, and nothing counted them; a unit costs ~400-430 us, so about 40 s at the ceiling, and Office's default theme costs 34 units per title-and-content slide, so about 2,600 such slides fit); each slide, and each layout and master a slide's placeholders inherit from, is streamed once for this (a DTD in one is refused), and every relationships part of the presentation is held to 10,000 entries, and all of them to 50,000 together. A .docx is also refused when a table cell spans, or a row skips, more than 1,000 grid columns (w:gridSpan, w:gridBefore, w:gridAfter; Word's tables are at most 63 columns wide), or carries such a value python-docx cannot read: python-docx yields a cell once per spanned column and unstructured re-reads it per yield, so a 950-byte file with one cell spanning 400,000 columns took 53 s, and at 2^31 - 1 python-docx would build a ~17 GB tuple. It is refused outright when an element of document.xml carries more than 256 attributes or sees more than 256 namespace declarations in scope (its own and its ancestors'): writers put at most a few dozen attributes on an element (the most found in Word, LibreOffice and python-docx output was twelve) and Word declares about 35 namespaces, while lxml reads attribute values in time quadratic in their number (one paragraph of 50,000 empty attributes, a 145 KB file, kept the guard itself busy for 40 s before; the attributes are now counted before any is read) and libxml2 resolves every copied element's namespace by walking the declarations in scope (8,000 of them used by 8,000 elements took 0.6 s per copy, quadrupling per doubling). It is also refused outright when a namespace declaration's URI is longer than 1,024 characters or its prefix longer than 64 (checked where it is declared, before any name under it is read; Office namespaces are under 100 characters): lxml rebuilds every element and attribute name as "{URI}local" on each read, so one 8 MB URI used through a short prefix by 3,000 elements, a 44 KB file, ran the guard itself out of a 3 GB address space, and a 1 MB URI on 1,024 attribute names grew it by ~0.5 GB (the guard now also keeps only the URIs a paragraph uses, not every name); when a body-level paragraph holds more than 1,024 namespace declarations (Word declares up to five per inline picture, python-docx two): lxml's remove(), which python-docx calls on a paragraph copy per rendered page break, costs the square of the declarations in the removed subtree (40,000 one-declaration elements took 0.4-0.8 s per removal, and six page breaks before them, a 142 KB file, took 5 s to partition and were accepted); and when a table row has more than 256 cells (four times Word's 63-column maximum) or spans more than 2,048 grid columns: python-docx resolves a cell continuing a vertical merge by reading the span of every earlier cell in its row and searching the row above, recursively up the merge, so a merged row costs its width squared (two rows of 1,000 cells, the second all continuing, a 37 KB file, took 6-7 s per read of the cells, and unstructured reads them twice per table); and when a table row python-docx reads has more than 256 children that are not cells, or a table more than 256 children before or between two of its rows (elements, comments and processing instructions, w:tblPr and w:tblGrid included): every step up a vertical merge looks up its row's grid_before by scanning the row's children and finds the row above by walking every sibling between the two, so a row padded with 200,000 empty elements after its cell, a 1.6 KB file, took 7.6 s per read of the cells, and 64 merged columns with 200,000 empty elements between each two of 26 rows, an 81 KB file, took 58 s per read, accepted at 0.09 and 0.90 of the run-work ceiling. Word's rows carry w:trPr, w:tblPrEx, bookmark, comment, permission and proofing markers and at most one content-control or custom-XML wrapper per cell, and its tables nothing between rows but such markers and wrappers of row groups; the content of a wrapper, and anything after a table's last row, is not walked and not capped. It is also refused when the repeated work python-docx and unstructured would do, estimated by streaming document.xml once without building a tree (document.xml itself is bounded by the 128 MiB parsed-part ceiling), exceeds one of seven ceilings, each holding one known fan-out (one bounded part or element turned into many times its work or memory) to a measured order of magnitude, about 45 s or a few hundred MB at the slowest layout found: the section lookup (python-docx finds each section's paragraphs and tables with a reverse-axis XPath whose result libxml2 sorts by walking sibling links, costing up to (paragraphs and tables up to the section's end) x (body nodes) steps per section at ~5 ns while the body fits in cache and up to ~100 ns for a large body of attribute-heavy nodes, so the sum of that product over sections is held to 450 million; before, 1,240 paragraphs and 2 million three-attribute bookmarks, a 234 KiB file, were accepted and took 121 s); the section count times each section's linear work (body nodes, plus the nodes python-docx's _sectPrs XPath visits and the pairs its union compares, weighted), held to 10 million units; the header/footer references, each counted at the referenced part's size, held to 12 MiB (a read costs up to ~3.5 us per byte: 20 references to a 1.2 MB header of empty runs took ~73 s), plus the union steps each read evaluates in the part, at 29 steps per byte (a header holding a table before 8,000 empty paragraphs and 40,000 empty elements, referenced by ten sections, a 37 KB file, took 35 s and was counted at 0.23 of the ceiling before; the referenced parts are now streamed for this, once each); the style lookups, the non-empty paragraphs (and page-break fragments) times the styles part's entries (at least the 6 of python-docx's default styles part, which it creates when there is none) plus one per 32 of their attributes and one per 32 document relationships, held to 3 million (50 paragraphs beside 300,000 styles, an 805 KB file, took 132 s before); the page-break splitting, K x (K + 3) x S squared summed over paragraphs with K rendered page breaks and S the widest child list in them, held to 9 billion (one run with 600 page breaks, a 37 KB file, ran for over 180 s before); the text extraction, about five reads of every run and a walk of every table row and cell per paragraph fragment, with a table cell counted once per grid column it spans (multiplied through nested tables), its content other than runs included at one unit per 256 nodes (unstructured walks a cell's children once per yield: 30 rows of one cell spanning 1,000 columns with 60,000 empty elements, a 54 KB file, were accepted at 0.10 of the ceiling, and three such rows took 5 s to partition), its paragraphs and tables at one unit each per yield (an empty paragraph costs ~20 us per yield: 32,000 of them in one cell spanning 1,000 columns would take ~10 minutes and were counted at 0.09 of the ceiling), and the node-set unions python-docx evaluates over a cell's paragraphs and tables, a paragraph's runs and hyperlinks (for a body-level paragraph, with unstructured's third branch, the runs inside an inline drawing of each of its runs, whose nodes are not the paragraph's children, so the union is counted at (nodes selected) x max(child nodes, nodes selected): one run whose inline drawing holds a run, before 10,000 plain runs, a 37 KB file, was accepted at 0.04 of the ceiling and took 0.37 s per evaluation, and before 40,000, 8.9 s; the nodes inside those drawings are counted too, once per node selected, since sorting two runs of one drawing walks the drawing's nodes after them: a run and a hyperlink around a drawing holding 1,000 runs before 100,000 empty elements, a 38 KB file, took 0.31-0.39 s per evaluation at 0.04 of the ceiling) and a run's text elements (and, in a document with no sections, over the body's paragraphs and tables): libxml2 merges each union's branches and sorts the result in up to (nodes selected) x (child nodes) steps once a later branch's node precedes an earlier one's, up to ~115 ns per step and read measured end to end, so each step is priced at 120 ns and every cell's, paragraph's and run's union counted six times, multiplied like the rest of its work (one cell spanning 1,000 columns holding 16,000 empty paragraphs and 16,000 empty tables, a 37 KB file, was accepted at 0.09 of the ceiling and took ~1.5 s per yield, about 25 minutes; a hyperlink before 8,000 runs and 40,000 empty elements in one paragraph, 38 KB, was accepted at 0.03 and took 15 s, and 8,000 w:t before a w:br and 40,000 empty elements in one run 14 s, each quadrupling per doubling), a cell continuing a vertical merge also counting the largest earlier cell of its table (a cell continues exactly as python-docx and unstructured read it: the first w:vMerge of its first w:tcPr, with no w:val or continue; a cell carrying any other w:vMerge, even beside or after one that continues, is counted once per spanned column, and an encoding the guard read differently, such as w:val="x" on a cell spanning 1,000 columns, used to go uncounted), and a row its gridBefore/gridAfter columns and python-docx's steps up the vertical merges its cells continue (one step per row of the merge, each priced at the cells whose spans it reads and the nodes it walks: the two rows' nodes, the continuing row's children up to its first w:trPr and that w:trPr's content wherever it sits (one after 256 continuing cells holding 100,000 children, a 38 KB file, added ~0.3 s per read at 0.04 of the ceiling), and the table's children between the two rows; from the spans and gridBefore as python-docx reads them: one column merged down 300 rows takes ~45,000 steps and 8 s to partition, and 64 columns merged down 50 rows took 42 s per read of the cells while the guard counted ~32,000 units of the 1.5 million before), held to 1.5 million units (120 paragraphs of 2,479 one-character runs, a 76 KB file, took 40 s, and the cost was bounded only by the 128 MiB part ceiling before); and the bytes copied beyond one read, held to 128 MiB: two copies of a paragraph per rendered page break (python-docx builds a preceding and a following fragment per break, each a deep copy of the rest of the paragraph, and unstructured keeps them until the paragraph is done; 80 breaks before 3 MB of text, a 40 KB file, kept ~230 MB more, and 250 breaks before 90 MB of text would keep ~22 GB), its text, attribute values, namespace declarations, 128 bytes per node and per declaration and 288 per attribute counted (a copied empty attribute keeps ~275 bytes: 20 breaks before 200 elements of 256 empty attributes, a 40 KB file, kept ~310 MB, and such attributes counted nothing before), plus the text after the paragraph and the declarations on the document and body elements of the namespaces it uses, which every copy carries (8 breaks before a 2 MB namespace URI, a 39 KB file, kept ~29 MB, and such declarations went uncounted before; a URI that long is now refused outright), and the text of a spanned cell once per extra column or of a merged cell once per continued row, at 64 bytes per byte of text, since unstructured keeps every copy as a string and twice more HTML-escaped in its row's and its table's HTML, where a " becomes " and one emoji makes a string four bytes per character (up to 52 bytes per byte: 20 extra copies of a 1 MB cell of quotes and one emoji, a 38 KB file, kept ~1 GB and were counted as 20 MB before; 300 continued rows under a 1 MB cell, a 38 KB file, kept ~930 MB and took 21 s). A continued row is counted as a copy of the largest earlier cell of its table, so a table whose continued rows times that cell exceed about 2 MiB of text (200 continued rows beside a 10 KB cell) is refused even when the merged cells are small. The ceiling is a count, not a measurement: each item is priced at about the most its copy was measured to keep, and the shapes measured kept less than they were counted. The seven share one budget: a document whose works' shares of their ceilings sum to more than 1 is refused, so one near several ceilings at once costs no more than one at a single ceiling. These ceilings bound the fan-outs above, not a document's total parse time or memory, which stay linear in its elements and text with a large per-element cost (see the known gaps below). Because they price every step at the slowest layout measured and share one budget, they also refuse long ordinary documents that python-docx would partition in under a minute; measured on documents python-docx writes: a single section of more than about 11,300 one-run paragraphs, a Word-like document (300 styles, five sections, a table) of more than about 5,250-5,850 paragraphs of 5-10 formatted runs, or more than about 580 one-paragraph sections (about 180 ten-paragraph ones), as a mail merge to individual documents writes; likewise one table column merged down more than about 545 rows, or every cell of a 64-column table continuing down 27 rows (26 with cell widths set). Long theses and books can exceed these. A slide entry or header/footer reference that does not resolve is refused too, and so is a .docx/.pptx without [Content_Types].xml or whose main part, slides, priced slide layouts and masters, or styles, settings, header and footer parts do not carry the content type python-pptx/python-docx build that kind of part from (resolved from [Content_Types].xml as they resolve it: the part's Override, matched without regard to case, else the Default of its extension, a later entry winning): both libraries pick a part's class by its content type, not by the relationship that reaches it, so a slide's layout relationship pointing at another slide made python-pptx read that slide's own layout, which the guard never priced (300 placeholders over a 300-placeholder layout reached that way, a 33 KB file, were counted at 1,200 units instead of about 90,000), and a styles or settings relationship pointing at a second document part made python-docx read that part's styles or settings, past the 5,000-entry caps. Every XML part the guard parses or streams (package and part relationships, presentation.xml, document.xml, the .docx settings part and the header/footer parts its sections reference, and, in an .xlsx, every part openpyxl's load parses) is refused if it carries a document type declaration, with or without an internal subset: python-docx parses without resolving entities, so each entity reference stays in its tree as a node its per-section lookup walks, which the streaming count of document.xml cannot see; OPC (ECMA-376 Part 2) forbids DTDs in the parts it defines (content types, relationships, core properties), and Office writes none in the XML parts it generates; an SVG image it stores may keep one, but no loader parses images. The declaration is refused in the part's bytes, before any parser the guard drives reads it: any <! before the root element that does not open a comment is refused, while this check passes comments and processing instructions before the root, and comments, CDATA sections and processing instructions inside it (a CDATA section before the root is refused, and the part walkers refuse more than 64 comments and processing instructions outside the root, and the .xlsx checks refuse one nested deeper than directly under the root of the styles or a workbook skeleton part) (none of the 4,770 XML members of 257 local Office files, leaving out one attack file made for this change, has a declaration, a comment or a CDATA section). The check had run at the root element's first event, by which libxml2 has read the whole internal subset, and declarations need no = for the start-tag count to see: a 17.9 MB document.xml (or slide) of one million attribute declarations held 424 MB in the guard (a 128 MiB part about 3 GB; 6.8 million, 122 MiB deflating from 16 MiB, were reported at 2.5 GB and 12 s), a relationships, header or skeleton part of 9-15 MB held 190-280 MB, and attribute-list defaults for xmlns: names added namespace declarations to the root that its bytes did not show; an .xlsx part was refused at the parsers' doctype callbacks, but lxml's push parser had first buffered the whole subset. Each is now refused before its parser receives more than the <! of the declaration, at no measurable memory. Legacy .doc/.ppt uploads are converted only when they start with the OLE compound-file signature (anything else, such as a zip container renamed .doc, is refused before soffice runs), via a soffice wrapper with a 120 s process-group timeout, per-call profile isolation and a 512 MiB ceiling on the converted file it reads back (checked after soffice exits, so it limits what is read, not what soffice writes to the per-call temporary directory within the timeout); soffice's memory is not capped, so the timeout is its only resource bound. RTF/EPUB/RST/Org/ODT uploads convert to HTML via a sandboxed pandoc wrapper (--sandbox needs pandoc 2.15 or newer: the bundled pypandoc-binary ships pandoc 3, and with an older pandoc every such conversion fails rather than running unsandboxed) with a 90 s process-group timeout, a 2 GiB pandoc heap cap (on Linux, an address-space limit of heap plus 512 MiB when the pandoc build rejects RTS options), and an output file that is size-checked before it is read; ODT text is now extracted from pandoc's HTML rather than from an intermediate .docx, and .odt is offered whenever the ODT loader and the pandoc bridge are installed (python-docx is no longer needed for it). The wrapper locates pandoc the same way pypandoc does, so the bundled pypandoc-binary copy is used. Email (.eml) uploads now index the message body only: attachments are no longer partitioned, since unstructured otherwise hands each one to its own auto-partitioner outside these guards (a .doc/.ppt attachment to soffice and an .rtf/.rst/.org/.odt/.epub attachment to pandoc with no timeout or memory cap, a .docx/.pptx/.xlsx attachment to its parser without the zip-container checks); the same applies to an Outlook .msg uploaded as .eml. Previously these converters ran with no timeout (and pandoc with no memory cap) and the parsers read container entries of any size, so a hostile or pathological file could exhaust memory or pin an indexing worker indefinitely. Documents beyond these bounds, ordinary long or complex ones included, are now rejected instead of indexed (the upload reports "Could not extract text from docx file", or the file's type, and the server logs "Refused document: it exceeds the parsing limits for its format", with no file or entry name), for example a worksheet with more than 128 MiB of XML, a container over 1 GiB uncompressed, an archive using BZIP2/LZMA/ZSTD compression, a workbook listing one worksheet part under several sheet entries, a workbook with a number format code over 1,024 characters or more than 65,490 cell formats, a presentation listing one slide under several slide entries, a presentation of more than about 2,600 title-and-content slides under Office's default theme (fewer under templates with more shapes per layout and master), a .docx with more than 1,000 sections or 20,000 rendered page breaks, a .docx of more than about 5,000-11,000 paragraphs (see above), a table cell spanning more than 1,000 columns, a table row of more than 256 cells or 256 other children, an element with more than 256 attributes, a namespace URI of more than 1,024 characters, a paragraph with more than 1,024 namespace declarations, a paragraph whose rendered page breaks would copy more than 128 MiB, a styles part of more than 5,000 entries, or header/footer references totalling more than 12 MiB, a .doc that is really a zip container, a .docx/.pptx/.xlsx with a mimetype member or without its main part, or a pandoc-backed document with on the order of 10 MB of text or more, which needs more than 90 s or 2 GiB to convert with the bundled pandoc. Images and charts in .xlsx chartsheets were never indexed and are now not loaded either. Known gaps, not addressed here: .xlsx memory follows cell references rather than XML size, because pandas pads every row to the widest row (a few-KB workbook with cells XFD1 and A300 materialises 300 x 16384 cells, and XFD1 with A1048576 would need hundreds of GiB), and a shared string, stored once, is written out once per referencing cell by unstructured's to_html, so a long string referenced by many cells multiplies; repeated references inside pandoc's own readers (such as an EPUB spine listing one chapter many times) are not counted, leaving pandoc bounded by its heap cap and timeout only; the total parse time and memory of an accepted .docx are not bounded: they stay linear in its elements and text with a large per-element cost (about 0.6-2 ms for a trivial paragraph, 3-9 ms for an ordinary python-docx-written one: 11,300 one-run paragraphs took 31 s, 5,600 paragraphs of seven formatted runs beside 300 styles 49 s; 35-65 ms for text that triggers unstructured's per-element classification, where a US city/state/ZIP regex backtracks for ~40 ms on text starting with 80 or more letters without a space or comma and langdetect runs per element at ~25 ms when the document as a whole is not one language, so an accepted document of a few thousand such paragraphs runs for minutes; one 3 MB paragraph took 43 s and ~300 MB), which only a wall-clock and memory limit on the in-process parse would bound; and the in-process parsers (python-docx, python-pptx, openpyxl, pandas, unstructured) run with no timeout.