Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent: Fix crash with pathological fetch output (#34253)

Cole Miller5b61b8c8ed64
diff --git a/crates/assistant_tools/src/fetch_tool.rs b/crates/assistant_tools/src/fetch_tool.rs
index c8fa600e831..54d49359bae 100644
--- a/crates/assistant_tools/src/fetch_tool.rs
+++ b/crates/assistant_tools/src/fetch_tool.rs
@@ -69,10 +69,9 @@ impl FetchTool {
.to_str()
.context("invalid Content-Type header")?;
let content_type = match content_type {
- "text/html" => ContentType::Html,
- "text/plain" => ContentType::Plaintext,
+ "text/html" | "application/xhtml+xml" => ContentType::Html,
"application/json" => ContentType::Json,
- _ => ContentType::Html,
+ _ => ContentType::Plaintext,
};
match content_type {
diff --git a/crates/html_to_markdown/src/markdown_writer.rs b/crates/html_to_markdown/src/markdown_writer.rs
index a9caf7afa7a..c32205ae7b3 100644
--- a/crates/html_to_markdown/src/markdown_writer.rs
+++ b/crates/html_to_markdown/src/markdown_writer.rs
@@ -119,8 +119,10 @@ impl MarkdownWriter {
.push_back(current_element.clone());
}
- for child in node.children.borrow().iter() {
- self.visit_node(child, handlers)?;
+ if self.current_element_stack.len() < 200 {
+ for child in node.children.borrow().iter() {
+ self.visit_node(child, handlers)?;
+ }
}
if let Some(current_element) = current_element {