mirror of
https://github.com/openai/codex.git
synced 2026-05-02 20:32:04 +03:00
migrating execpolicy -> execpolicy-legacy and execpolicy2 -> execpolicy (#6956)
This commit is contained in:
17
codex-rs/execpolicy-legacy/src/sed_command.rs
Normal file
17
codex-rs/execpolicy-legacy/src/sed_command.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use crate::error::Error;
|
||||
use crate::error::Result;
|
||||
|
||||
pub fn parse_sed_command(sed_command: &str) -> Result<()> {
|
||||
// For now, we parse only commands like `122,202p`.
|
||||
if let Some(stripped) = sed_command.strip_suffix("p")
|
||||
&& let Some((first, rest)) = stripped.split_once(",")
|
||||
&& first.parse::<u64>().is_ok()
|
||||
&& rest.parse::<u64>().is_ok()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Err(Error::SedCommandNotProvablySafe {
|
||||
command: sed_command.to_string(),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user