mirror of
https://github.com/openai/codex.git
synced 2026-09-04 15:08:45 +00:00
core: require canonical context newlines
This commit is contained in:
@@ -84,6 +84,36 @@ fn parses_canonical_internal_model_context_fragment() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_internal_model_context_without_leading_wrapper_newline() {
|
||||
assert_eq!(
|
||||
InternalModelContextFragment::parse_canonical(
|
||||
"<codex_internal_context source=\"goal\">body\n</codex_internal_context>"
|
||||
),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_internal_model_context_without_trailing_wrapper_newline() {
|
||||
assert_eq!(
|
||||
InternalModelContextFragment::parse_canonical(
|
||||
"<codex_internal_context source=\"extension\">\nbody</codex_internal_context>"
|
||||
),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_internal_model_context_without_wrapper_newlines() {
|
||||
assert_eq!(
|
||||
InternalModelContextFragment::parse_canonical(
|
||||
"<codex_internal_context source=\"goal\">body</codex_internal_context>"
|
||||
),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn detects_legacy_goal_context_fragment() {
|
||||
assert!(is_contextual_user_fragment(&ContentItem::InputText {
|
||||
|
||||
@@ -83,8 +83,8 @@ impl InternalModelContextFragment {
|
||||
}
|
||||
|
||||
let body = body_and_close.strip_suffix(CONTEXT_END_MARKER)?;
|
||||
let body = body.strip_prefix('\n').unwrap_or(body);
|
||||
let body = body.strip_suffix('\n').unwrap_or(body);
|
||||
let body = body.strip_prefix('\n')?;
|
||||
let body = body.strip_suffix('\n')?;
|
||||
|
||||
Some(Self::new(
|
||||
InternalContextSource(source.to_string()),
|
||||
|
||||
Reference in New Issue
Block a user