open()、requests.get() 一樣。
在不信任的環境中,輸入必須先驗證與限制。不要把不受信任的輸入直接丟給 MarkItDown。在代管 / 伺服器應用中,任何可能受使用者控制的輸入, 都必須先驗證與限制,例如:
.. 穿越)169.254.169.254)convert() 故意很寬鬆:可吃本機檔、遠端 URI、bytes 流。請依用途收窄:
| 你的需求 | 該用 |
|---|---|
| 只讀本機檔案 | convert_local() |
| 自己控制 URI 抓取(proxy/驗證/快取) | 自己 requests.get() → convert_response() |
| 最大控制權 | 自己 open stream → convert_stream() |
第三方外掛的 convert() 會以你的權限執行任意程式碼——只安裝信任來源的外掛。
accepts() 也一樣是外部程式碼。
localhost,但同機其他程序仍可呼叫。convert_to_markdown 能讀伺服器使用者可讀的任何檔案 + 任何網路資料。MarkItDown performs I/O with the privileges of the current process. Likeopen()orrequests.get(), it will access resources that the process itself can access.
Do not pass untrusted input directly to MarkItDown. If any part of the input may be controlled by an untrusted user or system, such as in hosted or server-side applications, it must be validated and restricted before calling MarkItDown. Depending on your environment, this may include restricting file paths, limiting URI schemes and network destinations, and blocking access to private, loopback, link-local, or metadata-service addresses.
Prefer the narrowest conversion API that fits your use case. MarkItDown'sconvert()method is intentionally permissive and can handle local files, remote URIs, and byte streams. If your application only needs to read local files, callconvert_local()instead. If you need more control over URI fetching, callrequests.get()yourself and pass the response object toconvert_response(). For maximum control, open a stream to the input you want converted and callconvert_stream().