fix: isolate uploaded Markdown from application templates

#13
by GuillaumeSalouHF HF Staff - opened
Hugging Face org

Uploaded Markdown currently shares a filesystem-backed template path with generated cards. Keep imports in the current Streamlit session and return their text directly for preview, download and export. Render only the two built-in templates, resolved relative to the application directory.

This preserves ordinary Markdown uploads, including empty and UTF-8 files. Jinja-looking text inside an uploaded card is now literal text. Invalid UTF-8 receives a validation message before export or download.

Validation: seven unittest methods and thirteen complete local browser controls pass with the declared Streamlit 1.10.0 dependency. The original revision fails the relevant isolation/rendering regressions and the same HTTP no-overwrite control. Browser coverage includes filename confinement, literal rendering, independent sessions, upload removal, preview navigation, downloads and invalid input. The exporter is exercised with recording Hub API doubles; no production export or deployment was tested.

Run the included tests with python -m unittest discover -s tests -v after installing the application dependencies. The dependency set is unchanged.

Publish this branch
This branch is in draft mode, publish it to be able to merge.

Sign up or log in to comment