load_yaml: Fix include spec parsing of pipes
_INCLUDE_PATH_RE allows the pipe character in the target-path part of a jw.include spec such as 'target.path|file.yaml'. The greedy match then consumes further pipes, so a file name that itself contains a pipe is misparsed: the target swallows part of the file name and the remainder becomes the (nonexistent) file to open. Dots are needed in the target part for nested paths, but a pipe can never be part of a target path. Drop the pipe from the character class so that the first pipe always separates the target path from the file name. Add a regression test with a pipe in the file name. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.84.2 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
1fd3c75c08
commit
e6f3833716
1 changed files with 12 additions and 1 deletions
|
|
@ -972,6 +972,17 @@ class TestIncludeWithPath:
|
|||
data = load_yaml(pathlib.Path(base) / 'main.yaml')
|
||||
assert data['section']['opt'] == 'val'
|
||||
|
||||
def test_include_pipe_in_filename(self, temp_dir: Callable) -> None:
|
||||
"""The first pipe separates target and file, pipes stay in the file."""
|
||||
base = temp_dir(
|
||||
[
|
||||
('weird|name.yaml', 'pip: ed\n'),
|
||||
('main.yaml', 'jw.include: section|weird|name.yaml\n'),
|
||||
]
|
||||
)
|
||||
data = load_yaml(pathlib.Path(base) / 'main.yaml')
|
||||
assert data['section']['pip'] == 'ed'
|
||||
|
||||
def test_include_plain_and_path_mixed(self, temp_dir: Callable) -> None:
|
||||
"""Mix plain and path-based includes in same document."""
|
||||
base = temp_dir(
|
||||
|
|
|
|||
Loading…
Reference in a new issue