mirror of
https://github.com/openai/codex.git
synced 2026-04-25 23:24:55 +00:00
Fix execpolicy parsing for multiline quoted args (#9565)
## What Fix bash command parsing to accept double-quoted strings that contain literal newlines so execpolicy can match allow rules. ## Why Allow rules like [git, commit] should still match when commit messages include a newline in a quoted argument; the parser currently rejects these strings and falls back to the outer shell invocation. ## How - Validate double-quoted strings by ensuring all named children are string_content and then stripping the outer quotes from the raw node text so embedded newlines are preserved. - Reuse the helper for concatenated arguments. - Ensure large SI suffix formatting uses the caller-provided locale formatter for grouping. - Add coverage for newline-containing quoted arguments. Fixes #9541. ## Tests - cargo test -p codex-core - just fix -p codex-core - cargo test -p codex-protocol - just fix -p codex-protocol - cargo test --all-features
This commit is contained in:
committed by
GitHub
parent
0fa45fbca4
commit
f815fa14ea
@@ -28,6 +28,10 @@ pub fn format_with_separators(n: i64) -> String {
|
||||
formatter().format(&Decimal::from(n)).to_string()
|
||||
}
|
||||
|
||||
fn format_with_separators_with_formatter(n: i64, formatter: &DecimalFormatter) -> String {
|
||||
formatter.format(&Decimal::from(n)).to_string()
|
||||
}
|
||||
|
||||
fn format_si_suffix_with_formatter(n: i64, formatter: &DecimalFormatter) -> String {
|
||||
let n = n.max(0);
|
||||
if n < 1000 {
|
||||
@@ -58,7 +62,7 @@ fn format_si_suffix_with_formatter(n: i64, formatter: &DecimalFormatter) -> Stri
|
||||
// Above 1000G, keep whole‑G precision.
|
||||
format!(
|
||||
"{}G",
|
||||
format_with_separators(((n as f64) / 1e9).round() as i64)
|
||||
format_with_separators_with_formatter(((n as f64) / 1e9).round() as i64, formatter)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user