Let WriteFiles write includes that leave the folder when asked
AllowParentPaths is off by default, so WriteFiles still refuses a path with .. in it. Absolute paths are refused either way. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,7 @@ The model is read with each setting that a controller moves taken at the control
|
||||
## Writing and building
|
||||
|
||||
- `Document.Write` writes one file, and `WriteFiles` writes the main file and each file it includes, through a `FileWriter`. They take `WriteOptions`: `InlineIncludes` puts included files into the main file, `ExpandVariables` replaces variables with their values, and `LineEnding` sets the line break. The zero value writes each file as it was read.
|
||||
- `Write` and `WriteTo` return an error for a document with includes unless `InlineIncludes` is set, as the files they hold would be lost. `WriteFiles` also returns an error for an include whose path is absolute or leaves the folder, and for a file included more than once that would be written differently each time.
|
||||
- `Write` and `WriteTo` return an error for a document with includes unless `InlineIncludes` is set, as the files they hold would be lost. `WriteFiles` also returns an error for an include whose path is absolute or leaves the folder (`AllowParentPaths` opts in to `..` paths, not absolute ones), and for a file included more than once that would be written differently each time.
|
||||
- `Build` makes a new document from an `Instrument`, with `BuildOptions`: `SplitFiles` puts regions in included files, `Variables` hoists repeated values into `#define`s and the samples' folder into `default_path`, and `Indent` sets the indent. Reading the result gives the instrument back, except for the opcodes and headers the typed model doesn't hold. It returns an error for a value that can't be written, such as a sample path with a line break in it.
|
||||
|
||||
## Includes
|
||||
@@ -91,7 +91,7 @@ Errors wrap one of these, for `errors.Is`:
|
||||
An instrument's text decides what the library does, so a file from elsewhere can't be trusted to be small or to stay in its folder.
|
||||
|
||||
- **Limits.** `Parse` stops at the limits in `Limits`: includes nest at most 16 deep, and the files and what their variables expand to may hold 16 MB. `WithLimits` changes both. It reads no more than the limit from a reader.
|
||||
- **Paths.** The paths in `#include` and `sample` come from the text and can be absolute or hold `..`. A `Resolver` that reads from a disk, and a `FileWriter` that writes to one, need to keep to the instrument's folder. `ParseFile` does, through `fs.FS`, and `WriteFiles` refuses a path that leaves the folder. `Region.Sample` is as the text gives it, and the host resolves it.
|
||||
- **Paths.** The paths in `#include` and `sample` come from the text and can be absolute or hold `..`. A `Resolver` that reads from a disk, and a `FileWriter` that writes to one, need to keep to the instrument's folder. `ParseFile` does, through `fs.FS`, and `WriteFiles` refuses a path that leaves the folder unless `AllowParentPaths` is set. `Region.Sample` is as the text gives it, and the host resolves it.
|
||||
|
||||
## Concurrency
|
||||
|
||||
|
||||
Reference in New Issue
Block a user