fix(parser): preserve quote metadata for mixed quoted/unquoted words#2045
Closed
chaliy wants to merge 1 commit into
Closed
fix(parser): preserve quote metadata for mixed quoted/unquoted words#2045chaliy wants to merge 1 commit into
chaliy wants to merge 1 commit into
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 8f91288 | Commit Preview URL | Jun 12 2026, 01:34 AM |
There was a problem hiding this comment.
Pull request overview
This PR aims to preserve quote metadata when a double-quoted segment is immediately followed by adjacent unquoted content, preventing unintended expansions (notably heredoc-body expansion and quoted metacharacters) while still enabling glob expansion on truly unquoted glob characters.
Changes:
- Updated
read_double_quoted_stringto avoid downgrading concatenated double-quoted segments toToken::Word, returningToken::QuotedWordorToken::QuotedGlobWordinstead. - Removed the now-unused
has_quoted_expansiontracking in the double-quote lexer path. - Added integration regression tests for partially quoted heredoc delimiters and mixed quoted/unquoted words containing quoted metacharacters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
crates/bashkit/src/parser/lexer.rs |
Adjusts token classification for concatenated double-quoted segments to preserve quote metadata. |
crates/bashkit/tests/integration/blackbox_security_tests.rs |
Adds regression tests for partially quoted heredoc delimiters and mixed quoted/unquoted word quote semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1336
to
+1339
| if has_glob { | ||
| return Some(Token::QuotedGlobWord(content)); | ||
| } | ||
| if has_quoted_expansion { | ||
| return Some(Token::QuotedWord(content)); | ||
| } | ||
| return Some(Token::Word(content)); | ||
| return Some(Token::QuotedWord(content)); |
Comment on lines
+1337
to
+1347
| #[tokio::test] | ||
| async fn quoted_glob_metacharacter_with_unquoted_suffix_stays_literal() { | ||
| let mut bash = tight_bash(); | ||
| let result = bash.exec(r#"echo "*"x"#).await.unwrap(); | ||
|
|
||
| assert_eq!( | ||
| result.stdout, "*x\n", | ||
| "glob metacharacter from quoted segment was expanded" | ||
| ); | ||
| } | ||
|
|
Comment on lines
1331
to
1335
| let before_len = content.len(); | ||
| self.read_continuation_into(&mut content); | ||
| let has_glob = content[before_len..] | ||
| .chars() | ||
| .any(|c| matches!(c, '*' | '?' | '[')); |
chaliy
added a commit
that referenced
this pull request
Jun 12, 2026
Closes #2045 Words mixing quoted and unquoted segments (e.g. "*"*.txt) lost quote metadata during lexing: quoted-segment metacharacters were passed raw to glob expansion, causing them to expand. Escapes glob metacharacters in quoted ranges before returning QuotedGlobWord, and tightens regression tests to create matching files so a broken lexer would fail deterministically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Superseded by #2054 — rebased cleanly on main.