# agent: Fix crash with pathological fetch output \(\#34253\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/5b61b8c8ed6469c3b12aed6d396561d2c4aee17b)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 5b61b8c8ed6469c3b12aed6d396561d2c4aee17b

Requested commit: 5b61b8c8ed6469c3b12aed6d396561d2c4aee17b

Commit: 5b61b8c8ed6469c3b12aed6d396561d2c4aee17b

Tree: 8a346f173b88dea7f2e118656c53e33768407d7d

Author: Cole Miller

Committer: GitHub

## Message

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

Closes #34029

The crash is due to a stack overflow in our `html_to_markdown`
conversion; I've added a maximum depth of 200 for the recursion in that
crate to guard against this kind of thing.

Separately, we were treating all content-types other than `text/plain`
and `application/json` as HTML; I've changed this to only treat
`text/html` and `application/xhtml+xml` as HTML, and fall back to
plaintext. (In the original crash, the content-type was
`application/octet-stream`.)

Release Notes:

- agent: Fixed a potential crash when fetching large non-HTML files.
```

## Parents

- [625ce12a3e170fb3f8a1e48a9e04b804b2d462e2](https://git.cafe/gitcafe/zed/commit/625ce12a3e170fb3f8a1e48a9e04b804b2d462e2?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/5b61b8c8ed6469c3b12aed6d396561d2c4aee17b?format=markdown)
