Skip to content

fix(config): handle quoted commas and escapes in TOML loader - #416

Open
Pybsama wants to merge 1 commit into
AVIDS2:mainfrom
Pybsama:fix/toml-loader-arrays-escapes
Open

Pybsama wants to merge 1 commit into
AVIDS2:mainfrom
Pybsama:fix/toml-loader-arrays-escapes

Conversation

@Pybsama

@Pybsama Pybsama commented Nov 30, 2026

Copy link
Copy Markdown

Summary

Fixes three parsing edge cases in src/config/toml-loader.ts (parseTomlValue):

  1. Commas inside quoted array items and trailing commas: Replaced body.split(',') with a quote- and bracket-aware splitter (splitTomlArray) so patterns/keywords containing commas (e.g. exclude_patterns = ["**/*.{ts,tsx}", 'a,b']) and trailing commas parse cleanly, while malformed empty slots (["a", , "b"]) and unclosed quotes are rejected.
  2. Basic string escapes (unescapeBasicString): Uses a single-pass escape lookup (\\, \", \n, \r, \t, \b, \f) instead of chained .replace(/\\"/g, ...).replace(/\\\\/g, ...) so combinations like \\\\" decode accurately.
  3. Minimum length guard: Requires raw.length >= 2 before stripping surrounding quotes so a lone " or ' raises Unsupported TOML value rather than returning an empty string.

Regression tests

Added tests in tests/config/toml-loader.test.ts covering quoted commas, trailing commas, nested escape sequences, and malformed empty slots / unterminated quotes.

Verification

  • npm run build:workspaces -> exit 0
  • npm run lint (tsc --noEmit) -> exit 0
  • npm run build -> exit 0
  • npx vitest run tests/config/ -> 10 test files passed (92 tests passed)

(AI-assisted: drafted and verified locally with an LLM coding assistant; all code and tests reviewed and run locally.)

…scapes in TOML loader

Signed-off-by: sama Pyb <peiyibopybsama@gmail.com>
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