-
-
Notifications
You must be signed in to change notification settings - Fork 974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rmarkdown::render()
corrupts input file
#2534
Comments
Thanks for the report. For context about what happens here: There is no check against supported extension - so any file can indeed be passed to What is happening when .rds is passed, is rmarkdown/R/html_document_base.R Line 151 in c306a43
This process will read to the input file and sometimes write to the input file. So rmarkdown/R/html_document_base.R Lines 253 to 258 in c306a43
@yihui it seems we do not have indeed any check on the extension regarding the supported input file. Should it be a check related to what knitr support or do you think it is safe to consider only known input ? I see Lines 348 to 349 in c306a43
Meaning it seems |
… character vector: https://github.com/rstudio/htmltools/blob/a8a3559edbfd9dda78418251e69273fa9dfeb9bc/R/tags.R#L1581-L1583 so we need to compare the collapsed version vs the extracted value later in identical()
Yes, we should definitely avoid writing to the original input file. 07ec182 should fix this issue (the bug seems to have existed for 10 years and no one has discovered it before). Actually we can get rid of this I searched in the project and it seems most other Line 93 in 65916c3
I'm not sure if checking extensions is a robust way. Checking if the file is text or binary may be better, but there is no 100% robust way AFAIK. Anyway, #2535 should fix this issue. |
Thanks for the quick fix - I did not think this part was off...
Yeah it may not be true always, we are still a but blocked by Pandoc version.
Even if not robust, maybe this is better than allowing to use |
Awesome. Thanks for the prompt response and quick fix. The error is not triggered any more as tested using #2536. Still, I am terrified by the |
Co-authored-by: Yihui Xie <[email protected]>
@cderv I agree it will be safer to disallow running @J-Moravec Yes, it looks scary. In the case of |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Issue:
Made a typo and instead of
rmarkdown::render("report.rmd")
wrotermarkdown::render("report.rds")
. To my surprise,rmarkdown
finished without error, but therds
file was mangled. This shouldn't happen.Why this is an issue:
Somewhere in the pipeline, the input file is being modified. This means that potentially, the call of
rmarkdown::render(input)
can corrupt theinput
file. This breaks the assumption of the call being safe.MRE:
Reproduced on both the latest cran and the development version of
rmarkdown
.Output of
xfun::session_info("rmarkdown")
The text was updated successfully, but these errors were encountered: