From 44c38abbbb8a726c060ae787e22413e3c9a3dad8 Mon Sep 17 00:00:00 2001
From: Robert Sparks <rjsparks@nostrum.com>
Date: Thu, 8 Dec 2022 13:55:15 -0600
Subject: [PATCH] fix: in htmlization ignore html files that do not parse as
 html (#4850)

---
 ietf/doc/models.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ietf/doc/models.py b/ietf/doc/models.py
index 587dfd1d7..2ad6a0729 100644
--- a/ietf/doc/models.py
+++ b/ietf/doc/models.py
@@ -571,7 +571,10 @@ class DocumentInfo(models.Model):
             return None
 
         # get body
-        body = etree.HTML(html).xpath("//body")[0]
+        etree_html = etree.HTML(html)
+        if etree_html is None:
+            return None
+        body = etree_html.xpath("//body")[0]
         body.tag = "div"
         if classes:
             body.attrib["class"] = classes