nushell/crates/nu-parser/src
Yash Thakur b1e591f84c
Fix unterminated loop in parse_record (#15246)
Fixes #15243

# Description

As noted in #15243, a record with more characters after it (e.g.,
`{a:b}/`) will cause an OOM due to an infinite loop, introduced by
#15023. This happens because the entire string `{a:b}/` is lexed as one
token and passed to `parse_record`, where it repeatedly lexes until it
hits the closing `}`. This PR detects such extra characters and reports
an error.

# User-Facing Changes

`{a:b}/` and other such constructions will no longer cause infinite
loops. Before #15023, you would've seen an "Unclosed delimiter" error
message, but this PR changes that to "Invalid characters."

```
Error: nu::parser::extra_token_after_closing_delimiter

  × Invalid characters after closing delimiter
   ╭─[entry #5:1:7]
 1 │  {a:b}/
   ·       ┬
   ·       ╰── invalid characters
   ╰────
  help: Try removing them.
```

# Tests + Formatting

# After Submitting
2025-03-05 21:02:03 +01:00
..
deparse.rs Fix quoting in to nuon and refactor quoting functions (#14180) 2024-10-29 07:43:26 -05:00
exportable.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
flatten.rs Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
known_external.rs Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
lex.rs 14523 all comments should be prefixed with space tab or be beginning of token (#14616) 2024-12-25 21:31:51 +08:00
lib.rs Fix quoting in to nuon and refactor quoting functions (#14180) 2024-10-29 07:43:26 -05:00
lite_parser.rs Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
parse_keywords.rs add attr category @category to custom command attributes (#15137) 2025-02-18 15:35:52 -06:00
parse_patterns.rs Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
parse_shape_specs.rs udpate rust toolchain to rust 1.81.0 (#14473) 2024-11-29 21:46:58 +01:00
parser.rs Fix unterminated loop in parse_record (#15246) 2025-03-05 21:02:03 +01:00
type_check.rs Rework operator type errors (#14429) 2025-02-12 20:03:40 -08:00