Skip to content

Reject empty push lists and cyclic syntax variables - #724

Open
SebTardif wants to merge 1 commit into
trishume:masterfrom
SebTardif:fix/syntax-load-push-and-variables
Open

SebTardif wants to merge 1 commit into
trishume:masterfrom
SebTardif:fix/syntax-load-push-and-variables

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

Loading a syntax file panicked or overflowed the stack on two malformed inputs.

push: [[]] and set: [[]] indexed the first item of an empty list. variables: { loop: '{{loop}}' } recursed in resolve_variables until the stack overflowed. The same recursion ran from SyntaxSetBuilder::build when extends merged that variable into a child regex.

Both now return ParseSyntaxError. An empty inner list is a type mismatch, the same error as a context rule that is not a mapping. A variable that expands back to itself is VariableCycle. A child that inherits the cycle is hidden and reported in SyntaxSetBuilder warnings, which is how a regex that cannot compile is already refused.

cargo test --lib parsing::yaml_load::tests is 26 passed. Before the change, empty_inner_push_or_set_list_is_an_error panicked at index 0, and variable_that_expands_to_itself_is_an_error overflowed the stack (STATUS_STACK_OVERFLOW).

An empty inner push or set list indexed the first item and panicked
while loading. A {{variable}} that expands to itself recursed until
the stack overflowed, including after extends merged that variable
into a child regex.

Both cases now return ParseSyntaxError. A cyclic variable inherited
through extends is refused the same way as a regex that cannot compile.

Tests: empty_inner_push_or_set_list_is_an_error,
variable_that_expands_to_itself_is_an_error,
variables_that_expand_through_each_other_are_an_error,
extends_cyclic_variable_does_not_hang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant